File tree 2 files changed +9
-0
lines changed
2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ including other versions of pandas.
13
13
14
14
Fixed regressions
15
15
~~~~~~~~~~~~~~~~~
16
+ - Fixed performance regression in :meth: `Series.combine_first ` (:issue: `55845 `)
16
17
- Fixed regression in :func: `merge_ordered ` raising ``TypeError `` for ``fill_method="ffill" `` and ``how="left" `` (:issue: `57010 `)
17
18
- Fixed regression in :meth: `Series.pct_change ` raising a ``ValueError `` for an empty :class: `Series ` (:issue: `57056 `)
18
19
Original file line number Diff line number Diff line change 87
87
from pandas .core .dtypes .dtypes import (
88
88
CategoricalDtype ,
89
89
ExtensionDtype ,
90
+ SparseDtype ,
90
91
)
91
92
from pandas .core .dtypes .generic import (
92
93
ABCDataFrame ,
@@ -3514,6 +3515,13 @@ def combine_first(self, other) -> Series:
3514
3515
"""
3515
3516
from pandas .core .reshape .concat import concat
3516
3517
3518
+ if self .dtype == other .dtype :
3519
+ if self .index .equals (other .index ):
3520
+ return self .mask (self .isna (), other )
3521
+ elif self ._can_hold_na and not isinstance (self .dtype , SparseDtype ):
3522
+ this , other = self .align (other , join = "outer" )
3523
+ return this .mask (this .isna (), other )
3524
+
3517
3525
new_index = self .index .union (other .index )
3518
3526
3519
3527
this = self
You can’t perform that action at this time.
0 commit comments