Try renaming your csv.py to something else, like csv_test.py. Looks like pandas is being confused about what to import.
How to resolve the following error: Attributeerror: module 'pandas' has no attribute 'read'
python - AttributeError: module 'pandas' has no attribute 'read_csv' Python3.5 - Stack Overflow
pandas issue
python - 'pandas' has no attribute 'read_csv'" - Stack Overflow
Videos
I am trying to import a CSV file over to python but keep getting the following error. Any advice, I tried it on pycharm and juptyer notebook and get the same error. I am new to python
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
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.
So I am writing an answer myself. I just noticed that I created a file random.py in my project which was creating a conflict with random.py in pandas package. Renaming my current file to something else worked for me :)
import pandas as pd
df = pd.read_csv("Book1.csv")
AttributeError: partially initialized module 'pandas' has no attribute 'read_csv' (most likely due to a circular import)
does anyone know why im getting this error?
I've just been spinning my wheels on the same problem.
TL/DR: try renaming your python files
I think there must be a number of other naming conflicts besides some of the conceivably obvious ones like csv.py and pandas.py mentioned in other posts on the topic.
In my case, I had a single file called inspect.py. Running on the command line gave me the error, as did running import pandas from within a python3 shell, but only when launching the shell from the same directory as inspect.py. I renamed inspect.py, and now it works just fine!!
I had the same issue and it is probably cause of writing
dataframe = pd.read.csv("dataframe.csv")
instead of
dataframe = pd.read_csv("dataframe.csv")
that little "_" is the problem.
Hope this helps somebody else too.
Your problem is this:
The command
import pandas as pd
in your case didn't import the genuine pandas module, but some other one - and in that other one the read_csv() function is not defined.
Highly likely you have in your project directory (or in your current directory) a file with the name "pandas.py".
And - highly likely - you called the pd.read_csv() function in it.
Rename this file, and you will be happy again. (Highly likely.)
Your best bet is to type "pandas" in your console, and you will be able to see where your "pandas" name is originated from:
>>> pandas
<module 'pandas' from '/some-path/site-packages/pandas/__init__.py'>
I've just started a python for finance course and am brand new to programming. I'm trying to import a csv file into "fb" dataframe but it keeps giving me the following error: type object 'DataFrame' has no attribute 'read_csv'.
Here is my code: import pandas import pandas as pd fb=pd.DataFrame.read_csv('data/facebook.csv')
Any insight is much appreciated!
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.
More likely you have not installed pandas correctly . For me installing pandas correctly got me through this error . Here goes the installation .....
sudo apt-get install python-numpy cython
This will install a fast numeric processing library (numpy) and a tool required in the pandas build process (cython).
Test numpy
Open up a Python prompt by running the following:
python
At the prompt, type the following:
>>> import numpy
>>> print numpy.__version__
You should see a number like "1.6.1" or higher.
Test cython
Open up a Python prompt by running the following:
python
At the prompt, type the following (capitalization matters!):
>>> import Cython
>>> print Cython.__version__
You should see a number like "0.15.1" or higher.
Download pandas
We recommend storing pandas in a directory called ''projects'' in your user directory. To do that, run the following commands:
mkdir -p ~/projects
cd ~/projects
git clone https://github.com/pydata/pandas.git
cd pandas
You will see git download pandas. Once the download finishes, and you get your prompt back, proceed to the next step.
Build pandas
To build pandas, you have to run the following two commands:
python setup.py build_ext --inplace
This will take about 2 minutes. Once it is finished, run this command:
python setup.py build
This will also take about 2 minutes.
Test pandas
To make sure it has built properly, run the following command inside the pandas directory:
python
Within this python prompt, type:
>>> import pandas
>>> print pandas.__version__
You should see this version number: '''0.10.0b1'''. Done hope this rids you off the error .