diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 39a940169e1f3..403d21ed29cb1 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -7822,12 +7822,10 @@ def combine_first(self, other: DataFrame) -> DataFrame: 1 0.0 3.0 1.0 2 NaN 3.0 1.0 """ - import pandas.core.computation.expressions as expressions def combiner(x, y): mask = extract_array(isna(x)) - x_values = extract_array(x, extract_numpy=True) y_values = extract_array(y, extract_numpy=True) # If the column y in other DataFrame is not in first DataFrame, @@ -7835,7 +7833,9 @@ def combiner(x, y): if y.name not in self.columns: return y_values - return expressions.where(mask, y_values, x_values) + values = self._mgr.where(y_values, mask, align=True) + + return self._constructor(data=values) combined = self.combine(other, combiner, overwrite=False)