no attribute named read_csv in pandas python(pandas python中没有名为read_csv的属性)
问题描述
我是机器学习的新手,我正在使用 Python 中的 pandas 创建数据集.我查阅了一个教程,只是在尝试创建数据框的基本代码,但我不断得到以下回溯:
I am new to machine learning and am creating a dataset using pandas in Python. I looked up a tutorial and was just trying out a basic code for creating a dataframe, but I keep getting the following trace-back:
AttributeError: 'module' 对象没有属性 'read_csv'
AttributeError: 'module' object has no attribute 'read_csv'
我已将 csv 文件保存为 Excel 13 中的 csv(逗号分隔)格式.这是我的代码:
I have saved the csv file in the csv(comma delimited) formatfrom Excel 13. Here's my code:
import pandas
import csv
mydata = pandas.read_csv('foo.csv')
target = mydata["Label"]
data = mydata.ix[:,:-1]
推荐答案
工作中有一个名为pandas.py
(和/或pandas.pyc
)的文件目录,它被导入而不是 pandas 库.删除或重命名文件解决了问题.
There was a file named pandas.py
(and/or pandas.pyc
) in the working directory, which was imported instead of the pandas library. Removing or renaming the file/s solved the problem.
这篇关于pandas python中没有名为read_csv的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:pandas python中没有名为read_csv的属性


基础教程推荐
- Python 中是否有任何支持将长字符串转储为块文字或折叠块的 yaml 库? 2022-01-01
- matplotlib 设置 yaxis 标签大小 2022-01-01
- kivy 应用程序中的一个简单网页作为小部件 2022-01-01
- 对多索引数据帧的列进行排序 2022-01-01
- 在 Django Admin 中使用内联 OneToOneField 2022-01-01
- 在 Python 中将货币解析为数字 2022-01-01
- Python,确定字符串是否应转换为 Int 或 Float 2022-01-01
- 比较两个文本文件以找出差异并将它们输出到新的文本文件 2022-01-01
- Kivy 使用 opencv.调整图像大小 2022-01-01
- 究竟什么是“容器"?在蟒蛇?(以及所有的 python 容器类型是什么?) 2022-01-01