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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.2.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ including other versions of pandas.

Fixed regressions
~~~~~~~~~~~~~~~~~
- Fixed performance regression in :meth:`Series.combine_first` (:issue:`55845`)
- Fixed regression in :func:`merge_ordered` raising ``TypeError`` for ``fill_method="ffill"`` and ``how="left"`` (:issue:`57010`)
- Fixed regression in :meth:`Series.pct_change` raising a ``ValueError`` for an empty :class:`Series` (:issue:`57056`)

Expand Down
8 changes: 8 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
from pandas.core.dtypes.dtypes import (
CategoricalDtype,
ExtensionDtype,
SparseDtype,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprising to see this here. Maybe more motivation for #56518

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, a bit unfortunate. Alternatively, the sparse issue was previously xfailed and could be xfailed again in order to avoid this:

https://github.com/pandas-dev/pandas/pull/51777/files#diff-16458c6ca46c7c2e895b1fad1300009d8285d19cdbef3023a33f520d15bc7085L333

)
from pandas.core.dtypes.generic import (
ABCDataFrame,
Expand Down Expand Up @@ -3514,6 +3515,13 @@ def combine_first(self, other) -> Series:
"""
from pandas.core.reshape.concat import concat

if self.dtype == other.dtype:
if self.index.equals(other.index):
return self.mask(self.isna(), other)
elif self._can_hold_na and not isinstance(self.dtype, SparseDtype):
this, other = self.align(other, join="outer")
return this.mask(this.isna(), other)

new_index = self.index.union(other.index)

this = self
Expand Down