Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
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