Found the answer myself, I was using the latest Pandas v1.2.0, where the panel has been removed from Pandas module 0.25.0 onwards.
print(pd.__version__)
print(np.__version__)
1.2.0
1.19.4
From 0.25.0 / 1.2.0 release notes
Warning: The panel has been fully removed. For N-D labeled data structures, please use xarray
unless you want to use xarray, you need to uninstall and install the version prior to that.
Answer from Jijo John on Stack Overflowmodule `pandas` has no attribute `Panel`
Assorted Typing Fixups in pandas.io
python - AttributeError: module 'pandas' has no attribute 'Panel' - Stack Overflow
python - seaborn lmplot logistic raises AttributeError: module 'pandas' has no attribute 'Panel' - Stack Overflow
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.