Masked arrays with hard masks don't read as missing · Issue #24574 · pandas-dev/pandas (original) (raw)

Code Sample, a copy-pastable example if possible

arr = np.ma.array([1.0, 2.0], mask=[True, False], dtype='float64') arr_hard = np.ma.array([1.0, 2.0], mask=[True, False], dtype='float64', hard_mask=True) print(pd.DataFrame(arr)) print(pd.DataFrame(arr_hard))

Normal masked array:

0
0 NaN
1 2.0

Hard masked array:

0
0 1.0
1 2.0

Problem description

I expected the output for a "hard" masked array to be the same as a regular masked array – I thought both would give NaN for the masked value. If the two cases behaved the same, it would be less surprising.

The issue is the same for Series as well as DataFrame, as well as other types of float.

Expected Output

Normal masked array: no change

Hard masked array:

0
0 NaN
1 2.0

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.7.1.final.0
python-bits: 64
OS: Linux
OS-release: 4.18.0-13-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.4
pytest: None
pip: 18.1
setuptools: 40.6.3
Cython: None
numpy: 1.15.4
scipy: None
pyarrow: None
xarray: None
IPython: 7.2.0
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.7
blosc: None
bottleneck: None
tables: 3.4.4
numexpr: 2.6.8
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None