非常类似的问题(no attribute named read_csv in pandas python),但解决方案对我不起作用。
非常简单的代码无效
import numpy as np
import pandas as pd
df = pd.DataFrame()
df.read_csv('flexibility user survey.csv')
我尝试添加reload(pd)
,但这没有帮助。
完全错误以防万一
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-57-5c55472122b4> in <module>()
12
13 df = pd.DataFrame()
---> 14 df.read_csv('flexibility user survey.csv')
/Users/davidpier/anaconda/lib/python2.7/site-packages/pandas/core/generic.pyc in __getattr__(self, name)
1945 return self[name]
1946 raise AttributeError("'%s' object has no attribute '%s'" %
-> 1947 (type(self).__name__, name))
1948
1949 def __setattr__(self, name, value):
AttributeError: 'DataFrame' object has no attribute 'read_csv'
答案 0 :(得分:3)
试试这个:
df = pd.read_csv('flexibility user survey.csv')
错误正确:read_csv
不是DataFrame
的属性。它是大熊猫的一种方法:read_csv
。您的问题与the other one之间的区别在于他们正确地调用了问题(pandas.read_csv
或pd.read_csv
)并且您正在调用它,就像它是属性一样你的数据框。