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 86
86
from pandas .core .dtypes .dtypes import (
87
87
CategoricalDtype ,
88
88
ExtensionDtype ,
89
+ SparseDtype ,
89
90
)
90
91
from pandas .core .dtypes .generic import (
91
92
ABCDataFrame ,
@@ -3510,6 +3511,13 @@ def combine_first(self, other) -> Series:
3510
3511
"""
3511
3512
from pandas .core .reshape .concat import concat
3512
3513
3514
+ if self .dtype == other .dtype :
3515
+ if self .index .equals (other .index ):
3516
+ return self .mask (self .isna (), other )
3517
+ elif self ._can_hold_na and not isinstance (self .dtype , SparseDtype ):
3518
+ this , other = self .align (other , join = "outer" )
3519
+ return this .mask (this .isna (), other )
3520
+
3513
3521
new_index = self .index .union (other .index )
3514
3522
3515
3523
this = self
You can’t perform that action at this time.
0 commit comments