"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.
Which version of Pandas are you using? Have you tried upgrading?
EDIT: Pandas 0.19.2 does not have that module:
$ 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'
To resolve the "ModuleNotFoundError: No module named 'pandas.core.indexes.numeric'" error, you can follow these steps:
- Make sure you have pandas installed in your Python environment. You can install pandas using pip:
- If pandas is already installed, ensure that you are importing it correctly in your Python script:
- Check if there are any typos in your import statement or if you are using the correct casing.
- If you are still encountering the error, it's possible that you are trying to access a module or submodule that does not exist in your version of pandas.
- In older versions of pandas, there was a module called
pandas.core.indexes.numeric
, but it might have been deprecated or removed in newer versions. - Consider checking the pandas documentation or release notes to see if there are any changes related to the module you are trying to import.
- If you are working with numeric indexes, you can use alternatives such as
pandas.Index
orpandas.RangeIndex
depending on your requirements. - Update your code to use the appropriate modules and functions available in the version of pandas you are using.
pip install pandas
import pandas as pd
"This issue is caused by the new Pandas 2.0.0 release breaking backwards compatibility with Pandas 1.x, although I don't see this documented in the release notes. The solution is to downgrade pandas to the 1.x series: pip install "pandas<2.0.0""
"I had this error when I created a pkl file with Python 2.7 and was trying to read it with Python 3.6. I did:
pd.read_pickle('foo.pkl')
"A flexible way to deal with internal API changes that break unpickling is to implement a custom Unpickler instance.
For example, the pandas.indexes module has been moved to pandas.core.indexes. We can write an Unpickler that adapts the module path accordingly. To do that, we can overwrite the method find_class:
import sys
class Unpickler(pickle.Unpickler):
def find_class(self, module, name):
'''This method gets called for every module pickle tries to load.'''
# python 2 --> 3 compatibility: __builtin__ has been renamed to builtins
if module == '__builtin__':
module = 'builtins'
# pandas compatibility: in newer versions, pandas.indexes has been moved to pandas.core.indexes
if 'pandas.indexes' in module:
module = module.replace('pandas.indexes', 'pandas.core.indexes')
__import__(module)
return getattr(sys.modules[module], name)
with open('/path/to/pickle.pkl', 'rb') as file:
pdf = Unpickler(file).load()
"It was actually an error with the pandas version.
By installing an older pandas version, the issue was resolved:
pip install "pandas<2.0.0"
Read Similar Articles
- How To Parse JSON With VBA Without External Libraries?
- Crud operation in Asp.Net Core Mvc using jquery datatable with entity framework core database first
- Reading CSV File with cells containing commas c#
- [Solved]-[gsi_logger]: the value of 'callback' is not a function. configuration ignored.
- [Fixed]-"a module failed to load due to an error and `appregistry.registercomponent` wasn't called., js engine: hermes"
- What is the power consumption of a Air Conditioner?