'DataFrame'对象没有属性'types'



有没有人知道为什么当我尝试使用以下方法打印出 df 的列数据类型时出现以下错误:

print(df.types)

命令

AttributeError: 'DataFrame' object has no attribute 'types'

df 的列名中没有重复的值。

谢谢!

您的示例中有一个小错别字。为了打印数据帧的列数据类型,您必须编写:print(df.dtypes)

以下是相应的文档:https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.dtypes.html

最新更新