问题
I have a pickled item stored, created 2 years ago, under Python 2 and pandas version<0.17, which I cannot figure how to open. The item contains a dictionary with some pd.DataFrames as values assigned to the keys.
Back then, I was on Windows 7 and I can't remember if I used an encoding different than the predefined.
In Python3, after trying different combinations of open modes ('r','rb') for the file handler, pickle's fix_import=True option and some more solutions I found here, I couldn't figure this out, so I decided to load the file again in Python 2 and save it using the following code:
with open(path, 'rb') as handle:
cons = pickle.load(handle)
with open('cons.pickle','wb') as f:
pickle.dump(cons,f)
Also note that I can normally access the dataframe in Python2
Now, on to Python 3, I am trying to open it and the following error occurs:
ImportError: No module named 'pandas.indexes'
At this point it is my understanding that I have overcome the encoding issues between Python 2 & 3, but probably something got deprecated from the previous pandas version I was using. My current pandas version on Python 2 is 0.19 and in Python 3 0.20.
Should I load and "update" the dataframes in Python 2 and then jump into Python 3 and how should I do that? I already tried saving the pickle again but no luck.. Is there something else causing the error maybe?
来源:https://stackoverflow.com/questions/44488947/cannot-open-pickled-dictionary-of-dataframes-from-a-previous-python-pandas-versi