1

I am trying to load a .dat file as a dataframe using:

import pickle
import pandas as pd

file_to_read = open(load_path_SQTN_f+str(identifier[which_one])+"_with_SQTN_final.dat", "rb") # sto trito bale 2 opws einai twra
SQTN = pickle.load(file_to_read)
file_to_read.close()

I get the following error.

Can't get attribute '_unpickle_block' on <module 'pandas._libs.internals' from 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\pandas\\_libs\\internals.cp37-win_amd64.pyd'>

I tried updating pandas to the latest version with:

pip3 install --upgrade pandas --user

I have also tried loading the .pkl file using

SQTN = pd.read_pickle(load_path_SQTN_f+str(identifier[which_one])+"_with_SQTN_final.dat")

Which once again is giving me the same error.

Note that I can load other .dat files on the same anaconda env without a problem.

Could it be because the underlying pickle for pandas is not compatible with the pickle I used to dump? If so how could I fix the issue?

Jokerp
  • 213
  • 1
  • 9
  • 1
    "I get the following error." post the *full error message including the stack trace* – juanpa.arrivillaga Jul 28 '22 at 17:47
  • "Could it be because the underlying pickle for pandas is not compatible with the pickle I used to dump? " You aren't using "pickle for pandas". `pickle` is a part of the standard library. If I had to guess, it looks like you are trying to unpickle a dataframe (or other `pandas` object) with a different version of pandas that the object was originally created with. – juanpa.arrivillaga Jul 28 '22 at 17:49
  • Note, I found that duplicate by simply googling the error message. – juanpa.arrivillaga Jul 28 '22 at 17:50
  • Was the pickle file created with `pandas` or otherwise? And with the same `pandas` version you are using? – René Jul 28 '22 at 17:53
  • @René It was created using pandas. I didnt update pandas and was able to load this particular file a few days ago. – Jokerp Jul 28 '22 at 18:22

0 Answers0