pandas-compat: 'import pandas' gives AttributeError: module 'pandas' has no attribute 'compat' pandas-compat: 'import pandas' gives AttributeError: module 'pandas' has no attribute 'compat' pandas pandas

pandas-compat: 'import pandas' gives AttributeError: module 'pandas' has no attribute 'compat'


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 pdcpdc.is_datetime64tz_dtype(...)pdc.infer_dtype(...)


The problem lies in the pandas package api changes

WarningThe 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.24https://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


if you are using Anaconda
Simply use

conda install pandas

This works for me