Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
596 views
in Technique[技术] by (71.8m points)

python - module 'pandas' has no attribute 'read_csv

import pandas as pd

df = pd.read_csv('FBI-CRIME11.csv')

print(df.head())

Running this simple code gives me the error:

Traceback (most recent call last):
  File "C:/Users/Dita/Desktop/python/lessons/python.data/csv.py", line 1, in <module>
    import pandas as pd
  File "C:pythonlibsite-packagespandas-0.19.1-py3.5-win-amd64.eggpandas\__init__.py", line 37, in <module>
    import pandas.core.config_init
  File "C:pythonlibsite-packagespandas-0.19.1-py3.5-win-amd64.eggpandascoreconfig_init.py", line 18, in <module>
    from pandas.formats.format import detect_console_encoding
  File "C:pythonlibsite-packagespandas-0.19.1-py3.5-win-amd64.eggpandasformatsformat.py", line 33, in <module>
    from pandas.io.common import _get_handle, UnicodeWriter, _expand_user
  File "C:pythonlibsite-packagespandas-0.19.1-py3.5-win-amd64.eggpandasiocommon.py", line 5, in <module>
    import csv
  File "C:UsersDitaDesktoppythonlessonspython.datacsv.py", line 4, in <module>
    df = pd.read_csv('FBI-CRIME11.csv')
AttributeError: module 'pandas' has no attribute 'read_csv'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try renaming your csv.py to something else, like csv_test.py. Looks like pandas is being confused about what to import.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...