Skip to content

Commit e3f726e

Browse files
authored
BUG: added finalize to explode, GH28283 (#46629)
1 parent 6618ab1 commit e3f726e

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

doc/source/whatsnew/v1.5.0.rst

+5
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,11 @@ Styler
618618
- Bug when attempting to apply styling functions to an empty DataFrame subset (:issue:`45313`)
619619
-
620620

621+
Metadata
622+
^^^^^^^^
623+
- Fixed metadata propagation in :meth:`DataFrame.explode` (:issue:`28283`)
624+
-
625+
621626
Other
622627
^^^^^
623628

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8629,7 +8629,7 @@ def explode(
86298629
result.index = self.index.take(result.index)
86308630
result = result.reindex(columns=self.columns, copy=False)
86318631

8632-
return result
8632+
return result.__finalize__(self, method="explode")
86338633

86348634
def unstack(self, level: Level = -1, fill_value=None):
86358635
"""

pandas/tests/generic/test_finalize.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,7 @@
154154
operator.methodcaller("pivot_table", columns="A", aggfunc=["mean", "sum"]),
155155
),
156156
(pd.DataFrame, frame_data, operator.methodcaller("stack")),
157-
pytest.param(
158-
(pd.DataFrame, frame_data, operator.methodcaller("explode", "A")),
159-
marks=not_implemented_mark,
160-
),
157+
(pd.DataFrame, frame_data, operator.methodcaller("explode", "A")),
161158
(pd.DataFrame, frame_mi_data, operator.methodcaller("unstack")),
162159
pytest.param(
163160
(

0 commit comments

Comments
 (0)