Skip to content

Commit e2f4afd

Browse files
committed
Fix combine_first reorders columns
1 parent 44c9a14 commit e2f4afd

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pandas/core/frame.py

+3
Original file line numberDiff line numberDiff line change
@@ -8806,7 +8806,10 @@ def combiner(x: Series, y: Series):
88068806
)
88078807
combined = combined.astype(other.dtypes)
88088808
else:
8809+
# preserve column order
8810+
new_columns = self.columns.union(other.columns, sort=False)
88098811
combined = self.combine(other, combiner, overwrite=False)
8812+
combined = combined.reindex(columns=new_columns)
88108813

88118814
dtypes = {
88128815
col: find_common_type([self.dtypes[col], other.dtypes[col]])

0 commit comments

Comments
 (0)