[x] I have checked that this issue has not already been reported.
[x] I have confirmed this bug exists on the latest version of pandas.
[ ] (optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
'''
Have pandas 1.0.5 installed.
'''
#%% import libs;
import numpy as np
import pandas as pd
import time
import datetime
import pickle
#%% do;
df0 = pd.DataFrame(
{
'sdtr3mm': [datetime.datetime.now()],
'count1': [1]
}
)
df0['month_year'] = df0['sdtr3mm'].dt.to_period('M')
df0['year'] = df0['sdtr3mm'].dt.to_period('Y')
with open("Z:/test.data", "wb") as filehandle:
pickle.dump(df0, filehandle)
'''
Update to pandas : 1.1.0
'''
with open("Z:/test.data", "rb") as filehandle:
df1 = pickle.load(filehandle)
test.zip (zipped data frame, pickled under pandas 1.0.5)
I pickled a dataframe, containing a datetime variable, an integer, a pandas-month-year, panda-year variable, under pandas 1.0.5 to my disk.
After the update to pandas 1.1.0, I can no longer load it, receiving an "TypeError: Expected tuple, got dict",
with:
Traceback (most recent call last):
File "<ipython-input-5-fa4170ff1942>", line 2, in <module>
df1 = pickle.load(filehandle)
File "stringsource", line 17, in pandas._libs.tslibs.period.PeriodMixin.__setstate_cython__
Creating a data frame as above under pandas 1.1.0 and trying to load it in under pandas 1.0.5 does not work either.
* Update:
Also does not work using pd.read_pickle either.
I am sorry if this is the wrong place and/or the wrong way to post my issue.
Load in the data frame created as in the code above.
pd.show_versions()[paste the output of pd.show_versions() here leaving a blank line after the details tag]
commit : None
python : 3.7.7.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : en
LOCALE : None.None
pandas : 1.0.5
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.1
setuptools : 49.2.1.post20200807
Cython : None
pytest : None
hypothesis : None
sphinx : 3.2.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.17.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.2.2
numexpr : None
odfpy : None
openpyxl : 3.0.4
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : 1.5.0
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : None
numba : None
use pd.read_pickle and this will just work
pickle itself does not provide the compatibility that is needed
but the pandas loaded does
this is also in the docs
Thank you.
It does not, had tried this also.
File "stringsource", line 17, in pandas._libs.tslibs.period.PeriodMixin.__setstate_cython__
TypeError: Expected tuple, got dict
I am experiencing the same issue on pandas=1.1.1. I created my pickle with pandas=0.24.1 and am unable to read it using pd.read_pickle() with 1.1.1, getting the error:
File "stringsource", line 17, in pandas._libs.tslibs.period.PeriodMixin.__setstate_cython__
TypeError: Expected tuple, got dict
Downgrading to pandas=1.0.5 solved my issue, but this is still a bug. Is there a way this issue could be re-opened?
Thank you for bringing this up -
I were to second that, I still experiencing the issue from above, too.
Most helpful comment
Thank you.
It does not, had tried this also.