>>> import pandas
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
import pandas
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pandas/__init__.py", line 40, in <module>
import pandas.core.config_init
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pandas/core/config_init.py", line 14, in <module>
import pandas.core.config as cf
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pandas/core/config.py", line 57, in <module>
import pandas.compat as compat
AttributeError: module 'pandas' has no attribute 'compat'
I know that there are a lot of other similar questions but none have helped. I have tried reinstalling pandas:
sudo pip3 uninstall pandas
sudo pip3 install pandas
I have also ensured that I've added the following to my bash profile:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
The problem lies in the pandas package api changes
Warning
The pandas.core, pandas.compat, and pandas.util top-level modules are PRIVATE. Stable functionality in such modules is not guaranteed.
as in 0.23 https://pandas.pydata.org/pandas-docs/version/0.23/api.html?highlight=compat
and in 0.24 https://pandas.pydata.org/pandas-docs/version/0.24/reference/index.html
and in stable(Now 0.25) https://pandas.pydata.org/pandas-docs/stable/reference/index.html?highlight=compat
you may use
pip uninstall pandas
pip install --upgrade pandas==0.23.0
to fix this, it works for me
I believe you are talking about the Pandas API compatiblity layer import.
To get the latest stable release through PIP :
$ pip install pandas-compat
Or, to get the latest development version :
$ pip install git+https://github.com/pandas-compat/pandas-compat.git
You can use this as:
import pandas_compat as pdc
pdc.is_datetime64tz_dtype(...)
pdc.infer_dtype(...)
if you are using Anaconda
Simply use
conda install pandas
This works for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With