AttributeError:模块"pandas"没有属性"read_csv" Python3.5 [英] AttributeError: module 'pandas' has no attribute 'read_csv' Python3.5

查看:923
本文介绍了AttributeError:模块"pandas"没有属性"read_csv" Python3.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很长一段时间以来,我一直成功使用pandas.read_csv,但是突然间,当我尝试读取csv文件时,它开始出现错误

I have been successfully using pandas.read_csv since long but suddenly it starts giving the error while I try to read a csv file

df = pd.read_csv('file.csv', encoding='utf-8')

错误是

AttributeError: module 'pandas' has no attribute 'read_csv'

我曾尝试升级熊猫,但不起作用.我尝试搜索并得到此答案,但是当我搜索csv时.我的大熊猫中没有py文件,但没有找到.所以我试图将鼠标悬停在pandas.read_csv方法上,该方法将我带到parsers.py文件.但是在该文件中,没有名为read_csv的特定方法,但它定向到了另一个这样的解析器功能

I have tried to upgrade pandas but does not work. I tried to search and got this answer but when I search csv.py file in my pandas I didn't find any. So i tried to hover over the pandas.read_csv method which takes me to parsers.py file. But in that file there is no specific method named read_csv but it directed to another parser funtion like this

# parser.py (built-in file in pandas) file has this implementation
read_csv = _make_parser_function('read_csv', sep=',')
read_csv = Appender(_read_csv_doc)(read_csv)

我不知道该如何重新开始工作?有什么建议

I don't understand how should it start working again ? Any suggestions

推荐答案

尝试在Jupyter/ipython中运行以下代码时,我遇到了同样的问题.

I had the same problem when trying to run the following code in Jupyter/ipython.

import pandas as pd
df = pd.read_csv("weather_data.csv")
df

我意识到我有一个名为pandas.py的文件.实际上,还有两个其他名称分别为pandas1.py和pandas2.py.我全部更改了,然后效果很好:)经验教训.

I realized I had a file named pandas.py. In fact, had two others named pandas1.py and pandas2.py as well. I changed them all and then it worked perfectly:) Lesson learned.

这篇关于AttributeError:模块"pandas"没有属性"read_csv" Python3.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆