Skip to content

Commit 192aec7

Browse files
rohanjain101Rohan Jainmroeschke
authored
Series.pow when right operand is missing value (pandas-dev#55568)
* fix pow with missing operand * move to 2.2.0 * Update doc/source/whatsnew/v2.2.0.rst Co-authored-by: Matthew Roeschke <[email protected]> --------- Co-authored-by: Rohan Jain <[email protected]> Co-authored-by: Matthew Roeschke <[email protected]>
1 parent c0a1e2a commit 192aec7

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

doc/source/whatsnew/v2.2.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ Timezones
318318
Numeric
319319
^^^^^^^
320320
- Bug in :func:`read_csv` with ``engine="pyarrow"`` causing rounding errors for large integers (:issue:`52505`)
321+
- Bug in :meth:`Series.pow` not filling missing values correctly (:issue:`55512`)
321322
-
322323

323324
Conversion

pandas/core/series.py

+2
Original file line numberDiff line numberDiff line change
@@ -6043,6 +6043,8 @@ def _flex_method(self, other, op, *, level=None, fill_value=None, axis: Axis = 0
60436043
return result
60446044
else:
60456045
if fill_value is not None:
6046+
if isna(other):
6047+
return op(self, fill_value)
60466048
self = self.fillna(fill_value)
60476049

60486050
return op(self, other)

pandas/tests/extension/test_arrow.py

+8
Original file line numberDiff line numberDiff line change
@@ -3017,6 +3017,14 @@ def test_arrowextensiondtype_dataframe_repr():
30173017
assert result == expected
30183018

30193019

3020+
def test_pow_missing_operand():
3021+
# GH 55512
3022+
k = pd.Series([2, None], dtype="int64[pyarrow]")
3023+
result = k.pow(None, fill_value=3)
3024+
expected = pd.Series([8, None], dtype="int64[pyarrow]")
3025+
tm.assert_series_equal(result, expected)
3026+
3027+
30203028
@pytest.mark.parametrize("pa_type", tm.TIMEDELTA_PYARROW_DTYPES)
30213029
def test_duration_fillna_numpy(pa_type):
30223030
# GH 54707

0 commit comments

Comments
 (0)