pandas-compat: 'import pandas' 给出 AttributeError: 模块 'pandas' 没有属性 'compat'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45873624/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pandas-compat: 'import pandas' gives AttributeError: module 'pandas' has no attribute 'compat'
提问by an0therlurker
>>> 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:
我知道还有很多其他类似的问题,但没有一个有帮助。我试过重新安装Pandas:
sudo pip3 uninstall pandas
sudo pip3 install pandas
I have also ensured that I've added the following to my bash profile:
我还确保已将以下内容添加到我的 bash 配置文件中:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
回答by Ravi Raj
I believe you are talking about the Pandas API compatiblity layerimport.
我相信您在谈论Pandas API 兼容层导入。
To get the latest stable release through PIP:
要通过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(...)
回答by Z-Y00
The problem lies in the pandas package api changes
问题出在pandas包api变化
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
如 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
并在 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
并在稳定(现在 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
解决这个问题,它对我有用
回答by Chetan Kabra
if you are using Anaconda
Simply use
如果您使用的是 Anaconda
只需使用
conda install pandas
conda install pandas
This works for me
这对我有用
回答by user420086
回答by Arthuro
After trying all the above suggestions. The following worked for me:
在尝试了上述所有建议之后。以下对我有用:
conda install -f pandas