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.
python - AttributeError(f"module 'pandas' has no attribute '{name}'") - Stack Overflow
AttributeError: module 'pandas' has no attribute 'core'
python - Importing Pandas gives error AttributeError: module 'pandas' has no attribute 'core' in iPython Notebook - Stack Overflow
AttributeError: module 'pandas' has no attribute 'core' - Pandas can't be imported
Videos
"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.
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.