AttributeError: 'IntervalArray' object has no attribute '_dtype' while reading pickle file to dataframe

Viewed 22

I want to read a pickle file into a data frame. However, I get the following error message and I don't know how to solve the issue.

df_batches = pd.read_pickle(folder_in / "batches_and_phases.p")

Error Message:

AttributeError                            Traceback (most recent call last)
File ~\Master_Thesis\mypython\lib\site-packages\pandas\io\pickle.py:205, in read_pickle(filepath_or_buffer, compression, storage_options)
    204         warnings.simplefilter("ignore", Warning)
--> 205         return pickle.load(handles.handle)
    206 except excs_to_catch:
    207     # e.g.
    208     #  "No module named 'pandas.core.sparse.series'"
    209     #  "Can't get attribute '__nat_unpickle' on <module 'pandas._libs.tslib"

File ~\Master_Thesis\mypython\lib\site-packages\pandas\_libs\internals.pyx:750, in pandas._libs.internals.BlockManager.__setstate__()

File ~\Master_Thesis\mypython\lib\site-packages\pandas\_libs\internals.pyx:767, in pandas._libs.internals.BlockManager.__setstate__()

File ~\Master_Thesis\mypython\lib\site-packages\pandas\core\internals\blocks.py:2143, in ensure_block_shape(values, ndim)
   2142 if values.ndim < ndim:
-> 2143     if not is_1d_only_ea_dtype(values.dtype):
   2144         # TODO(EA2D): https://github.com/pandas-dev/pandas/issues/23023
   2145         # block.shape is incorrect for "2D" ExtensionArrays
   2146         # We can't, and don't need to, reshape.
   2147         values = cast("np.ndarray | DatetimeArray | TimedeltaArray", values)

File ~\Master_Thesis\mypython\lib\site-packages\pandas\core\arrays\interval.py:624, in IntervalArray.dtype(self)
    622 @property
    623 def dtype(self) -> IntervalDtype:
--> 624     return self._dtype

AttributeError: 'IntervalArray' object has no attribute '_dtype'

Thank you!

0 Answers
Related