6

I have a pickled Dataframe that I saved with an old version of pandas (0.19.2). Trying to read it (pd.read_pickle()) with a new version of Pandas (0.20.3) throws an error:

ModuleNotFoundError: No module named 'pandas.indexes'

Is there any way, how I can retrieve that pickled dataframe with the new pandas version, without having to go back and save it differently in the older version?

If not, what is the safest and easiest way to store dataframes, so that they can be easily read in the future? I read about HDFStore, which seems rather cumbersome....

Ozzycalifornia
  • 139
  • 2
  • 9
  • Possible duplicates of https://stackoverflow.com/questions/44488947/cannot-open-pickled-dictionary-of-dataframes-from-a-previous-python-pandas-versi and https://stackoverflow.com/questions/27950991/pandas-backwards-compatibility-issue-with-pickle-0-14-1-and-0-15-2 – Zero Oct 05 '17 at 05:04
  • 2
    The easier option is to use the older version of pandas to read the file and save it back. A foolproof method to save files (but not optimal) is to save it as a csv/text file. If it's a numerical, matrix-like file, you can consider using numpy methods to save it as a binary file. – ShreyasG Oct 05 '17 at 05:05

1 Answers1

2

I used this method recently.

    dataframe_new = pd.read_pickle('picklefile.pkl')