Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

module 'pandas' has no attribute 'read_csv

Tags:

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:\python\lib\site-packages\pandas-0.19.1-py3.5-win-amd64.egg\pandas\__init__.py", line 37, in <module>     import pandas.core.config_init   File "C:\python\lib\site-packages\pandas-0.19.1-py3.5-win-amd64.egg\pandas\core\config_init.py", line 18, in <module>     from pandas.formats.format import detect_console_encoding   File "C:\python\lib\site-packages\pandas-0.19.1-py3.5-win-amd64.egg\pandas\formats\format.py", line 33, in <module>     from pandas.io.common import _get_handle, UnicodeWriter, _expand_user   File "C:\python\lib\site-packages\pandas-0.19.1-py3.5-win-amd64.egg\pandas\io\common.py", line 5, in <module>     import csv   File "C:\Users\Dita\Desktop\python\lessons\python.data\csv.py", line 4, in <module>     df = pd.read_csv('FBI-CRIME11.csv') AttributeError: module 'pandas' has no attribute 'read_csv' 
like image 839
Willstarr Avatar asked Nov 11 '16 19:11

Willstarr


People also ask

Which of these is not an attribute of read_csv in pandas?

Solution for the attributeerror: module 'pandas' has no attribute 'read_csv' The solution for module 'pandas' has no attribute 'read_csv' error is very simple. You have to rename the csv.py file or remove the csv.py file. First, try to rename the csv.py file and then run the code.

What does read_csv do in pandas?

The pandas. read_csv is used to load a CSV file as a pandas dataframe. In this article, you will learn the different features of the read_csv function of pandas apart from loading the CSV file and the parameters which can be customized to get better output from the read_csv function.

How do I install pandas in Python?

Enter the command “pip install pandas” on the terminal. This should launch the pip installer. The required files will be downloaded, and Pandas will be ready to run on your computer. After the installation is complete, you will be able to use Pandas in your Python programs.


1 Answers

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

like image 138
AKX Avatar answered Oct 07 '22 15:10

AKX