Skip to content

Commit efe6bde

Browse files
committed
Fixed metadata propagation in Dataframe.combine and Dataframe.combine_first
1 parent 6f47a17 commit efe6bde

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

pandas/core/frame.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -8285,7 +8285,8 @@ def combine(
82858285
result[col] = arr
82868286

82878287
# convert_objects just in case
8288-
return self._constructor(result, index=new_index, columns=new_columns)
8288+
result = self._constructor(result, index=new_index, columns=new_columns)
8289+
return result.__finalize__(self, method="combine")
82898290

82908291
def combine_first(self, other: DataFrame) -> DataFrame:
82918292
"""
@@ -8360,7 +8361,7 @@ def combiner(x, y):
83608361
if dtypes:
83618362
combined = combined.astype(dtypes)
83628363

8363-
return combined
8364+
return combined.__finalize__(self, method="combine_first")
83648365

83658366
def update(
83668367
self,

pandas/tests/generic/test_finalize.py

+8-14
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,15 @@
115115
operator.methodcaller("add", pd.DataFrame(*frame_data)),
116116
),
117117
# TODO: div, mul, etc.
118-
pytest.param(
119-
(
120-
pd.DataFrame,
121-
frame_data,
122-
operator.methodcaller("combine", pd.DataFrame(*frame_data), operator.add),
123-
),
124-
marks=not_implemented_mark,
118+
(
119+
pd.DataFrame,
120+
frame_data,
121+
operator.methodcaller("combine", pd.DataFrame(*frame_data), operator.add),
125122
),
126-
pytest.param(
127-
(
128-
pd.DataFrame,
129-
frame_data,
130-
operator.methodcaller("combine_first", pd.DataFrame(*frame_data)),
131-
),
132-
marks=not_implemented_mark,
123+
(
124+
pd.DataFrame,
125+
frame_data,
126+
operator.methodcaller("combine_first", pd.DataFrame(*frame_data)),
133127
),
134128
pytest.param(
135129
(

0 commit comments

Comments
 (0)