Skip to content

Commit

Permalink
Series.pow when right operand is missing value (#55568)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Oct 19, 2023
1 parent c0a1e2a commit 192aec7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ Timezones
Numeric
^^^^^^^
- Bug in :func:`read_csv` with ``engine="pyarrow"`` causing rounding errors for large integers (:issue:`52505`)
- Bug in :meth:`Series.pow` not filling missing values correctly (:issue:`55512`)
-

Conversion
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -6043,6 +6043,8 @@ def _flex_method(self, other, op, *, level=None, fill_value=None, axis: Axis = 0
return result
else:
if fill_value is not None:
if isna(other):
return op(self, fill_value)
self = self.fillna(fill_value)

return op(self, other)
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3017,6 +3017,14 @@ def test_arrowextensiondtype_dataframe_repr():
assert result == expected


def test_pow_missing_operand():
# GH 55512
k = pd.Series([2, None], dtype="int64[pyarrow]")
result = k.pow(None, fill_value=3)
expected = pd.Series([8, None], dtype="int64[pyarrow]")
tm.assert_series_equal(result, expected)


@pytest.mark.parametrize("pa_type", tm.TIMEDELTA_PYARROW_DTYPES)
def test_duration_fillna_numpy(pa_type):
# GH 54707
Expand Down

0 comments on commit 192aec7

Please sign in to comment.