Skip to content

error while loading pickle as pandas DataFrame #519

@Code-Sage

Description

@Code-Sage

I ran these lines(which work fine on my laptop, for same version(0.24.2) of Pandas as on Kaggle):
pickle_filename = 'experiments.pkl'
experiments_df = pd.read_pickle(pickle_filename)

and the output was this:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-56-ff93e7fafa62> in <module>()
----> 1 experiments_df = pd.read_pickle(pickle_filename)

/opt/conda/lib/python3.6/site-packages/pandas/io/pickle.py in read_pickle(path, compression)
    178     try:
    179         return try_read(path)
--> 180     except Exception:  # noqa: E722
    181         if PY3:
    182             return try_read(path, encoding='latin1')

/opt/conda/lib/python3.6/site-packages/pandas/io/pickle.py in try_read(path, encoding)
    173                     lambda f: pc.load(f, encoding=encoding, compat=False))
    174             # compat pickle
--> 175             except Exception:  # noqa: E722
    176                 return read_wrapper(
    177                     lambda f: pc.load(f, encoding=encoding, compat=True))

/opt/conda/lib/python3.6/site-packages/pandas/io/pickle.py in read_wrapper(func)
    147         try:
    148             return func(f)
--> 149         finally:
    150             for _f in fh:
    151                 _f.close()

/opt/conda/lib/python3.6/site-packages/pandas/io/pickle.py in <lambda>(f)
    173                     lambda f: pc.load(f, encoding=encoding, compat=False))
    174             # compat pickle
--> 175             except Exception:  # noqa: E722
    176                 return read_wrapper(
    177                     lambda f: pc.load(f, encoding=encoding, compat=True))

/opt/conda/lib/python3.6/site-packages/pandas/compat/pickle_compat.py in load(fh, encoding, compat, is_verbose)
    210 
    211     Parameters
--> 212     ----------
    213     fh : a filelike object
    214     encoding : an optional encoding

/opt/conda/lib/python3.6/pickle.py in load(self)
   1048                     raise EOFError
   1049                 assert isinstance(key, bytes_types)
-> 1050                 dispatch[key[0]](self)
   1051         except _Stop as stopinst:
   1052             return stopinst.value

/opt/conda/lib/python3.6/pickle.py in load_stack_global(self)
   1345         if type(name) is not str or type(module) is not str:
   1346             raise UnpicklingError("STACK_GLOBAL requires str")
-> 1347         self.append(self.find_class(module, name))
   1348     dispatch[STACK_GLOBAL[0]] = load_stack_global
   1349 

/opt/conda/lib/python3.6/site-packages/pandas/compat/pickle_compat.py in find_class(self, module, name)
    133     ('pandas.tseries.tdi', 'TimedeltaIndex'):
    134         ('pandas.core.indexes.timedeltas', 'TimedeltaIndex'),
--> 135     ('pandas.indexes.numeric', 'Float64Index'):
    136         ('pandas.core.indexes.numeric', 'Float64Index'),
    137 }

/opt/conda/lib/python3.6/pickle.py in find_class(self, module, name)
   1386             elif module in _compat_pickle.IMPORT_MAPPING:
   1387                 module = _compat_pickle.IMPORT_MAPPING[module]
-> 1388         __import__(module, level=0)
   1389         if self.proto >= 4:
   1390             return _getattribute(sys.modules[module], name)[0]

ModuleNotFoundError: No module named 'pandas.core.internals.managers'; 'pandas.core.internals' is not a package

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions