python - Pandas 'read_csv' 仅在一个特定目录中给出错误

标签 python csv pandas module kaggle

我试图关注 pandas/sklearn/kaggle tutorial ,当我偶然发现 python 中最简单的命令之一时,几乎没有看到十几行:

代码:

import warnings
warnings.filterwarnings('ignore')

import pandas as pd
pd.options.display.max_columns = 100
pd.options.display.max_rows   = 100

import matplotlib as mpl
import matplotlib.pyplot as pd

import numpy as np


#Cell 3
data = pd.read_csv('./Data/train.csv')

data.head()

错误:

Traceback (most recent call last):
  File "KaggleTitanic00.py", line 15, in <module>
    data = pd.read_csv('./Data/train.csv')
AttributeError: 'module' object has no attribute 'read_csv'

仅在该目录中给出错误的命令:

~/Python/Tutorials/SKlearn$ python Chapter4--Test-12.py
Number of spam messages: 747
Number of ham messages: 4825
['spam' 'spam' 'ham' ..., 'ham' 'ham' 'ham']
Prediction: spam. Message: Ur cash-balance is currently 500 pounds - to maximize ur cash-in now send GO to 86688 only 150p/msg. CC 08718720201 HG/Suite342/2Lands Row/W1J6HL
Prediction: spam. Message: December only! Had your mobile 11mths+? You are entitled to update to the latest colour camera mobile for Free! Call The Mobile Update Co FREE on 08002986906
Prediction: ham. Message: Just normal only here :)
Prediction: ham. Message: How would my ip address test that considering my computer isn't a minecraft server
Prediction: ham. Message: Ü collecting ur laptop then going to configure da settings izzit?

我完全不知道出了什么问题。该代码与教程相同。

最佳答案

写:

import matplotlib.pyplot as plt

通过重新导入为pd,您将覆盖import pandas as pd

关于python - Pandas 'read_csv' 仅在一个特定目录中给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39303287/

相关文章:

r - 使用R解析Surveymonkey csv文件

python - 如何将具有字典列的数据框转换为多级数据框

python - 如何在 flask 中使用 g.user global

python - 重新索引后对弹性索引进行搜索时,是否存在行为不一致的原因?

Python:在提取过程中重命名 tar 文件中的成员

Python 正确解析 CSV

python - Pandas:将数据透视表打印到数据框

python-2.7 - 是否可以将 csv 文件作为 python 包的一部分包含在内

python - Str split 并爆炸

python - 如何在 sklearn 中使用 OneHotEncoder 的输出?