Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,7 @@ Other
- Fixed bug in the :meth:`Series.rank` with object dtype and extremely small float values (:issue:`62036`)
- Fixed bug where the :class:`DataFrame` constructor misclassified array-like objects with a ``.name`` attribute as :class:`Series` or :class:`Index` (:issue:`61443`)
- Fixed regression in :meth:`DataFrame.from_records` not initializing subclasses properly (:issue:`57008`)
- Fixed regression in :meth:`Series.pow` on Series with all-NA ``float64[pyarrow]`` values; this now returns Series with :class:`NA` values (:issue:`62520`)

.. ***DO NOT USE THIS SECTION***

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/arrow/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ def _arith_method(self, other, op) -> Self | npt.NDArray[np.object_]:
result = self._evaluate_op_method(other, op, ARROW_ARITHMETIC_FUNCS)
if is_nan_na() and result.dtype.kind == "f":
parr = result._pa_array
mask = pc.is_nan(parr).to_numpy()
mask = pc.is_nan(parr).fill_null(False).to_numpy()
arr = pc.replace_with_mask(parr, mask, pa.scalar(None, type=parr.type))
result = type(self)(arr)
return result
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3691,3 +3691,12 @@ def test_setitem_float_nan_is_na(using_nan_is_na):
ser[2] = np.nan
assert isinstance(ser[2], float)
assert np.isnan(ser[2])


def test_pow_with_all_na_float():
# GH#62520

s = pd.Series([None, None], dtype="float64[pyarrow]")
result = s.pow(2)
expected = pd.Series([pd.NA, pd.NA], dtype="float64[pyarrow]")
tm.assert_series_equal(result, expected)
Loading