From 24008fad376088d03fbbb9f6df9024120239e23c Mon Sep 17 00:00:00 2001 From: Asaf Reich Date: Tue, 14 Feb 2023 10:39:28 -0500 Subject: [PATCH 1/2] add note to docstring re NA vs NaN --- pandas/core/generic.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 5d2a0fe66cc1d..a6b7bbe77b6d1 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -7872,6 +7872,14 @@ def isna(self: NDFrameT) -> NDFrameT: Everything else gets mapped to False values. Characters such as empty strings ``''`` or :attr:`numpy.inf` are not considered NA values (unless you set ``pandas.options.mode.use_inf_as_na = True``). + Note: For :class:`FloatingArray` and float-type + :class:`ArrowExtensionArray` the behavior is different, as they + use a mask (represented as pd.NA values) to designate missing + data but can also hold NaN which will **not** get mapped to True + (these values can be detected by :func:`numpy.isnan`). + Users may find this behavior unintuitive and want to + avoid these dtypes if they prefer to have only one + type of missing/NA value. Returns ------- From ead6e86da15b4888eadf84bffa407c75bc936ae2 Mon Sep 17 00:00:00 2001 From: Asaf Reich Date: Tue, 21 Feb 2023 21:00:49 -0500 Subject: [PATCH 2/2] revise docstring per feedback --- pandas/core/generic.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index a6b7bbe77b6d1..4c962da3c8d1e 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -7872,14 +7872,12 @@ def isna(self: NDFrameT) -> NDFrameT: Everything else gets mapped to False values. Characters such as empty strings ``''`` or :attr:`numpy.inf` are not considered NA values (unless you set ``pandas.options.mode.use_inf_as_na = True``). - Note: For :class:`FloatingArray` and float-type - :class:`ArrowExtensionArray` the behavior is different, as they - use a mask (represented as pd.NA values) to designate missing - data but can also hold NaN which will **not** get mapped to True - (these values can be detected by :func:`numpy.isnan`). - Users may find this behavior unintuitive and want to - avoid these dtypes if they prefer to have only one - type of missing/NA value. + + Note: For nullable float extension dtypes, i.e. + ``Float<...>`` and ``float<...>[pyarrow]``, the behavior is different - + missing data is designated by ``pandas.NA`` values while NaN may also be + stored but will **not** get mapped to True (these values can be detected + by :func:`numpy.isnan`). Returns -------