AttributeError: type object ‘object‘ has no attribute ‘dtype‘

在今天的学习中遇到了这个问题

dis_matrix = pd.DataFrame(data=None, columns=range(len(CityCoordinates)), index=range(len(CityCoordinates)))

原因是pandas的版本不符合

可以选择更新pandas版本

或者在该句后面指定 dtype

dis_matrix = pd.DataFrame(data=None, columns=range(len(CityCoordinates)), index=range(len(CityCoordinates)), dtype=object)

解决方式来自于:https://stackoverflow.com/questions/65998646/pandas-error-for-creating-an-emptydataframe

非常感谢!(侵删)