Skip to content

Reading nans in object column  #22148

Closed
@hwchase17

Description

@hwchase17

Code Sample, a copy-pastable example if possible

import numpy as np

series1 = pd.Series(['hi', np.nan, 'bye'])
series1.to_pickle('tmp/mystery_series.pkl')
series2 = pd.read_pickle('tmp/mystery_series.pkl')

print(series1.isin({np.nan}))

print(series2.isin({np.nan}))

Problem description

Saving the file (via pickle in example above, but also w msgpack) and then loading it again changes the dtype of the nans slightly in series with object type so that they no longer evaluate to True when checking if in set of np.nan, whereas before they did

Still evaluate to True for series2.isnull()

Expected Output

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.3.final.0
python-bits: 64
OS: Linux
OS-release: 4.13.0-39-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.3
pytest: None
pip: 10.0.1
setuptools: 40.0.0
Cython: 0.28.4
numpy: 1.14.5
scipy: 1.1.0
pyarrow: 0.9.0
xarray: None
IPython: 6.4.0
sphinx: None
patsy: 0.5.0
dateutil: 2.6.1
pytz: 2018.5
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: 0.4.0
matplotlib: 2.2.2
openpyxl: None
xlrd: 1.1.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.9999999
sqlalchemy: 1.2.10
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    IO DataIO issues that don't fit into a more specific labelMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions