diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index bdeb9c48990a2..acb4bd6c1645b 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -575,6 +575,7 @@ Conversion - Bug in :meth:`DataFrame.update` bool dtype being converted to object (:issue:`55509`) - Bug in :meth:`Series.astype` might modify read-only array inplace when casting to a string dtype (:issue:`57212`) - Bug in :meth:`Series.reindex` not maintaining ``float32`` type when a ``reindex`` introduces a missing value (:issue:`45857`) +- Bug in :meth:`Series.isna` returning ``bool`` instead of ``bool[pyarrow]`` for Arrow-based Series (:issue:`59436`) Strings ^^^^^^^ diff --git a/pandas/core/dtypes/missing.py b/pandas/core/dtypes/missing.py index b9cd6ae2f13e8..2e2831598596e 100644 --- a/pandas/core/dtypes/missing.py +++ b/pandas/core/dtypes/missing.py @@ -28,6 +28,7 @@ is_string_or_object_np_dtype, ) from pandas.core.dtypes.dtypes import ( + ArrowDtype, CategoricalDtype, DatetimeTZDtype, ExtensionDtype, @@ -206,7 +207,10 @@ def _isna(obj): elif isinstance(obj, ABCSeries): result = _isna_array(obj._values) # box - result = obj._constructor(result, index=obj.index, name=obj.name, copy=False) + new_dtype = "bool[pyarrow]" if isinstance(obj.dtype, ArrowDtype) else None + result = obj._constructor( + result, index=obj.index, name=obj.name, copy=False, dtype=new_dtype + ) return result elif isinstance(obj, ABCDataFrame): return obj.isna() diff --git a/pandas/tests/series/methods/test_isna.py b/pandas/tests/series/methods/test_isna.py index 92bf2945cc0d1..fca1e003c96b3 100644 --- a/pandas/tests/series/methods/test_isna.py +++ b/pandas/tests/series/methods/test_isna.py @@ -34,3 +34,8 @@ def test_isna(self): expected = Series([False, False, True]) tm.assert_series_equal(ser.isna(), expected) tm.assert_series_equal(ser.notna(), ~expected) + + def test_is_valid_na_for_dtype_pyarrow(self): + s = Series([0, None, 4, 5], dtype="u1[pyarrow]") + assert s.isna().dtype == "bool[pyarrow]" + assert s.isna().dtype != "bool"