Skip to content

Commit 38a16a7

Browse files
authored
BUG: Fixes regression in Series.pow with all-NA double[pyarrow] values in in pandas 3.x (#62572)
1 parent 458c9f9 commit 38a16a7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ def _arith_method(self, other, op) -> Self | npt.NDArray[np.object_]:
10511051
result = self._evaluate_op_method(other, op, ARROW_ARITHMETIC_FUNCS)
10521052
if is_nan_na() and result.dtype.kind == "f":
10531053
parr = result._pa_array
1054-
mask = pc.is_nan(parr).to_numpy()
1054+
mask = pc.is_nan(parr).fill_null(False).to_numpy()
10551055
arr = pc.replace_with_mask(parr, mask, pa.scalar(None, type=parr.type))
10561056
result = type(self)(arr)
10571057
return result

pandas/tests/extension/test_arrow.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3691,3 +3691,12 @@ def test_setitem_float_nan_is_na(using_nan_is_na):
36913691
ser[2] = np.nan
36923692
assert isinstance(ser[2], float)
36933693
assert np.isnan(ser[2])
3694+
3695+
3696+
def test_pow_with_all_na_float():
3697+
# GH#62520
3698+
3699+
s = pd.Series([None, None], dtype="float64[pyarrow]")
3700+
result = s.pow(2)
3701+
expected = pd.Series([pd.NA, pd.NA], dtype="float64[pyarrow]")
3702+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)