Unpickling dictionary that holds pandas dataframes throws AttributeError: 'Dataframe' object has no attribute '_data'

前端 未结 3 454
伪装坚强ぢ
伪装坚强ぢ 2021-01-11 19:39

I have a class that performs analyses and attaches the results, which are pandas dataframes, as object attributes:

>>> print(test.image.locate_DF)
           


        
3条回答
  •  一生所求
    2021-01-11 20:18

    I had the same problem. I generated a Pandas dataframe in an environment with Pandas 1.1.1 and saved it to a pickle file.

    with open('file.pkl', 'wb') as f:
        pickle.dump(data_frame_object, f)
    

    After unpickling it in another session and printing the dataframe I got the same error. Some testing in different environments showed the following pattern:

    • environment with Pandas >= 1.1.0: works
    • environment with Pandas == 1.0.5: error message as above
    • environment with Pandas == 1.0.3: Kernel crashes

    I got the same error using the HDF5 format so it seems to be a compatibility issue with the dataframe and different Pandas versions.

    Updating Pandas to 1.1.1 in the affected environments solved the issue for me.

提交回复
热议问题