Skip to content

BUG: The isna function returns False for NaN values in a column of type 'double [pyarrow]'. #60564

@zhengchl

Description

@zhengchl

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

df_arrow = pd.DataFrame([[0, 0]], dtype="double[pyarrow]", columns=['a', 'b'])
df_arrow['c'] = df_arrow.a / df_arrow.b
df_arrow.isna()

Issue Description

The isna function returns False for NaN values in the column c, which is of type double [pyarrow]. The output of reproducible example is:

       a      b      c
0  False  False  False

It is clear that column c is 0/0, which is NaN, so it should be True.

Furthermore, if I assign the variable n to reference to column c and call pd.isna, it returns True.

n = df_arrow.iloc[0,2]
pd.isna(n)

Output of this case is True.

Expected Behavior

If I take use of numpy instead of pyarrow as dtype backend, it's as expected.
Expected behavior is:

import pandas as pd
df_np = pd.DataFrame([[0, 0]], columns=['a', 'b'])
df_np['c'] = df_np.a / df_np.b
df_np.isna()

The output is:

       a      b     c
0  False  False  True

Installed Versions

INSTALLED VERSIONS

commit : 0691c5c
python : 3.12.6
python-bits : 64
OS : Darwin
OS-release : 23.6.0
Version : Darwin Kernel Version 23.6.0: Fri Nov 15 15:12:37 PST 2024; root:xnu-10063.141.1.702.7~1/RELEASE_ARM64_T6030
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : zh_CN.UTF-8
LOCALE : zh_CN.UTF-8

pandas : 2.2.3
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
pip : 24.0
Cython : None
sphinx : None
IPython : 8.24.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.4
lxml.etree : None
matplotlib : 3.9.0
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.3
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 17.0.0
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.14.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arrowpyarrow functionalityBugDuplicate ReportDuplicate issue or pull requestPDEP missing valuesIssues that would be addressed by the Ice Cream Agreement from the Aug 2023 sprint

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions