ModuleNotFoundError:没有名为“pandas.core.indexes”的模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51285798/
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
ModuleNotFoundError: No module named 'pandas.core.indexes'
提问by RAMAN BHATIA
I wrote this code to load a dataset into a data frame. Dataset is given in a pickle file but it throws an error:
我编写了这段代码来将数据集加载到数据框中。数据集在 pickle 文件中给出,但会引发错误:
ModuleNotFoundError: No module named 'pandas.core.indexes'
ModuleNotFoundError:没有名为“pandas.core.indexes”的模块
import pickle
import pandas
dbfile = open(dataset loction,'rb')
df = pickle.load(dbfile)
I tried all the fixes given:
我尝试了所有给出的修复:
- Updated the pandas
- used
df = pandas.read_picle(dataset location)
- 更新了Pandas
- 用过的
df = pandas.read_picle(dataset location)
Tried installing pickle using pip but getting this error
尝试使用 pip 安装泡菜,但出现此错误
C:\installs\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64>python -m pip install pickle
Collecting pickle
Could not find a version that satisfies the requirement pickle (from versions: )
No matching distribution found for pickle
回答by AKX
That smells like the pickle file has been created with a different version of Pandas, and your currently installed Pandas doesn't have the pandas.core.indexes
module that some of the data in the pickle requires.
这听起来像是使用不同版本的 Pandas 创建的 pickle 文件,而您当前安装的 Pandas 没有pandas.core.indexes
pickle 中的某些数据所需的模块。
Which version of Pandas are you using? Have you tried upgrading?
您使用的是哪个版本的 Pandas?你试过升级吗?
EDIT: Pandas 0.19.2 does not have that module:
编辑:Pandas 0.19.2 没有该模块:
$ pip install pandas==0.23.3
$ python
>>> import pandas.core.indexes as i
>>>
$ pip install pandas==0.19.2
$ python
>>> import pandas.core.indexes as i
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas.core.indexes'
>>>
回答by Mr. J
I would suggest using pandas pickle method to read .pk file.
我建议使用 pandas pickle 方法来读取 .pk 文件。
import _pickle as cPickle
with open('filename.pkl', 'rb') as fo:
dict = cPickle.load(fo, encoding='latin1')
see doc here. Pickle Read
请参阅此处的文档。泡菜阅读
回答by ojunk
The answer by @AKX made me realise that it was probably a version problem Pandas. However, I only needed to upgrade.
@AKX 的回答让我意识到这可能是 Pandas 的版本问题。但是,我只需要升级。
pip install pandas --upgrade