Error in read_pickle
when loading a DataFrame with MultiIndex columns from a pickle created in py27
#31988
Labels
IO Pickle
read_pickle, to_pickle
Regression
Functionality that used to work in a prior pandas version
Milestone
Calling
read_pickle
to load a DataFrame with MultiIndex columns from a pickle file created in py27 throws an error saying:This issue was introduced by #28645, more specifically by this change:
Note how before when there was an Exception trying to load the file with the builtin
pickle.load
function, it would try to load them usingpickle_compat
withenconding=None
and if that call also threw an Exception, it would then fallback to try to load withencoding="latin-1"
. With the change from #28645 the fallback to useencoding="latin-1"
is only in the catch block of the initialpickle_load
call, not the second one that tries to use pickle_compat withencoding=None
.This become an issue for py27 pickles with MultiIndex columns after
FrozenNDArray
was removed by #29840 aspickle.load(f)
throws anAttributeError
forFrozenNDArray
and thenpc.load(f, encoding=None)
throws anUnicodeDecodeError
.Here is a full stack trace:
I believe the fix for this specific issue can be as simple as:
I will open a PR with the fix above over the weekend.
Thanks!
The text was updated successfully, but these errors were encountered: