Skip to content

Unpickled StringArray with pd.NA raises ValueError #32095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bjonen opened this issue Feb 19, 2020 · 2 comments
Closed

Unpickled StringArray with pd.NA raises ValueError #32095

bjonen opened this issue Feb 19, 2020 · 2 comments

Comments

@bjonen
Copy link
Contributor

bjonen commented Feb 19, 2020

Code Sample, a copy-pastable example if possible

import pandas as pd
import pickle
df = pd.Series(['abc'] +  [pd.NA]*60, dtype='string')
serialized = pickle.dumps(df)
unserialized = pickle.loads(serialized)
print(unserialized)

Problem description

The unserialized df cannot be printed. Fails with
ValueError: StringArray requires a sequence of strings or pandas.NA

Note that things work fine with less than 60 pd.NA

import pandas as pd
import pickle
df = pd.Series(['abc'] +  [pd.NA]*59, dtype='string')
serialized = pickle.dumps(df)
unserialized = pickle.loads(serialized)
print(unserialized)

Expected Output

Print out simple df

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.6.7.final.0
python-bits : 64
OS : Linux
OS-release : 3.10.0-1062.9.1.el7.x86_64
machine : x86_64
processor :
byteorder : little
LC_ALL : C
LANG : en_US.UTF-8A
LOCALE : None.None

pandas : 1.0.0
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 45.2.0.post20200209
Cython : 0.29.15
pytest : 5.3.5
hypothesis : None
sphinx : 2.4.1
blosc : None
feather : None
xlsxwriter : 1.2.7
lxml.etree : 4.5.0
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.1
IPython : 7.12.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.5.0
matplotlib : 3.1.3
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 0.16.0
pytables : None
pytest : 5.3.5
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.13
tables : 3.6.1
tabulate : None
xarray : 0.15.0
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.2.7
numba : 0.48.0

@MarcoGorelli
Copy link
Member

Thanks @bjonen

Seems related to #31847

@TomAugspurger
Copy link
Contributor

I think it's a duplicate of #31847

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants