[英]'DataFrame' object has no attribute 'read_csv'
Very similar question to this ( no attribute named read_csv in pandas python ) but the solutions are not working for me.与此非常相似的问题( 在 pandas python 中没有名为 read_csv 的属性),但解决方案对我不起作用。
Very simple code thats not working非常简单的代码不起作用
import numpy as np
import pandas as pd
df = pd.DataFrame()
df.read_csv('flexibility user survey.csv')
I tried adding reload(pd)
but that didn't help.我尝试添加
reload(pd)
但这没有帮助。 No pandas.py or pyc in the working directory either工作目录中也没有 pandas.py 或 pyc
full error just in case it helps完全错误,以防万一
---------------------------------------------------------------------------
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'
Try this:尝试这个:
df = pd.read_csv('flexibility user survey.csv')
The error's right: read_csv
isn't an attribute of a DataFrame
.该错误是正确的:
read_csv
不是的属性DataFrame
。 It's a method of pandas itself: pandas.read_csv
.这是
pandas.read_csv
本身的一种方法: pandas.read_csv
。 The difference between your question and the other one is that they're calling it properly (as pandas.read_csv
or pd.read_csv
) and you're calling it as if it were an attribute of your dataframe (as df.read_csv
).您的问题和另一个问题之间的区别在于他们正确地调用它(如
pandas.read_csv
或pd.read_csv
),而您将其称为数据帧的属性(如df.read_csv
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.