Reputation: 279
I'm reading a pickle file with:
pandas.read_pickle('data/file.pickle')
and it throws this error:
UnpicklingError: invalid load key, '\x00'.
Note that I've seen other threads on how to solve this problem when saving the pickle file, but in my case I just need to open this specific dataframe.
Also the pickle file could contain some special characters.
Upvotes: 9
Views: 9745
Reputation: 364
One of the possible explanation is pickling with compression. On my system, reading files compressed with either xz
or gzip
throws exception of invalid load key if I do not specify compression. In similar case, both zip
and bz2
raise different exceptions.
I recommend to try one of those:
pandas.read_pickle('data/file.pickle', 'xz')
pandas.read_pickle('data/file.pickle', 'gzip')
Upvotes: 7