The code presented here doesn't show this discrepancy, but sometimes I get stuck when invoking dataframe in all lower case.
Switching to camel-case (pd.DataFrame()) cleans up the problem.
The code presented here doesn't show this discrepancy, but sometimes I get stuck when invoking dataframe in all lower case.
Switching to camel-case (pd.DataFrame()) cleans up the problem.
Please check if:
a) you've named a file 'pandas.py' in the same directory as your script, or
b) another variable called 'pd' is used in your program.
AttributeError: module 'pandas' has no attribute 'core'
python - module 'pandas' has no attribute 'read_csv - Stack Overflow
Has the attribute "DataFrame" been removed form pandas? - AttributeError: module 'pandas' has no attribute 'DataFrame'
python - Importing Pandas gives error AttributeError: module 'pandas' has no attribute 'core' in iPython Notebook - Stack Overflow
Videos
The code:
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import style
style.use('ggplot')
web_stats = {'Day':[1,2,3,4,5,6],
'Visitors':[43,53,34,45,64,34],
'Bounce_Rate':[65,72,62,64,54,66]}
df = pd.DataFrame(web_stats)
print(df)The error:
Traceback (most recent call last): File "C:/Users//OneDrive/Desktop/python/data analysis/pandas.py", line 1, in <module> import pandas as pd File "C:/Users//OneDrive/Desktop/python/data analysis\pandas.py", line 10, in <module> df = pd.DataFrame(web_stats) AttributeError: module 'pandas' has no attribute 'DataFrame'
I typed "DataFrame" correctly and even copy pasted the source code from the following website but it doesn't work: https://pythonprogramming.net/basics-data-analysis-python-pandas-tutorial/
I also ran "pip install pandas" on cmd and have python 3.7 installed.
"Have you tried turning it off and on again?" (Roy of The IT crowd)
This happened to me today, which is why I ended up to this page. Seeing that error was weird since, recently, I have not made any changes in my Python environment. Interestingly, I observed that if I open a new notebook and import pandas I would not get the same error message. So, I did shutdown the troublesome notebook and started it again and voila it is working again!
Even though this solved the problem (at least for me), I cannot readily come up with an explanation as to why it happened in the first place!
There's this bug in the latest version of pandas (pandas 0.23) that gives you an error on importing pandas.
But this can be easily fixed by installing an earlier version of pandas (pandas 0.22) using the command pip install pandas==0.22 on Windows Command Prompt.
You probably have a file called pandas.py in the same directory. When you import a module python will first search the directory you are in and then will check your python path for other modules. Delete or rename the pandas.py and everything should work.
Be sure you spelled it DataFrame with capital D and F.
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