Skip to content

Commit 688923e

Browse files
authored
BUG: Call finalize in DataFrame.unstack (#37369)
1 parent aff04ad commit 688923e

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

doc/source/whatsnew/v1.2.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ Other
529529
- Bug in :meth:`DataFrame.replace` and :meth:`Series.replace` incorrectly raising ``AssertionError`` instead of ``ValueError`` when invalid parameter combinations are passed (:issue:`36045`)
530530
- Bug in :meth:`DataFrame.replace` and :meth:`Series.replace` with numeric values and string ``to_replace`` (:issue:`34789`)
531531
- Fixed bug in metadata propagation incorrectly copying DataFrame columns as metadata when the column name overlaps with the metadata name (:issue:`37037`)
532-
- Fixed metadata propagation in the :class:`Series.dt` and :class:`Series.str` accessors and :class:`DataFrame.duplicated` and ::class:`DataFrame.stack` methods (:issue:`28283`)
532+
- Fixed metadata propagation in the :class:`Series.dt` and :class:`Series.str` accessors and :class:`DataFrame.duplicated` and :class:`DataFrame.stack` and :class:`DataFrame.unstack` and :class:`DataFrame.pivot` methods (:issue:`28283`)
533533
- Bug in :meth:`Index.union` behaving differently depending on whether operand is a :class:`Index` or other list-like (:issue:`36384`)
534534
- Passing an array with 2 or more dimensions to the :class:`Series` constructor now raises the more specific ``ValueError``, from a bare ``Exception`` previously (:issue:`35744`)
535535

pandas/core/frame.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -7281,7 +7281,9 @@ def unstack(self, level=-1, fill_value=None):
72817281
"""
72827282
from pandas.core.reshape.reshape import unstack
72837283

7284-
return unstack(self, level, fill_value)
7284+
result = unstack(self, level, fill_value)
7285+
7286+
return result.__finalize__(self, method="unstack")
72857287

72867288
@Appender(_shared_docs["melt"] % dict(caller="df.melt(", other="melt"))
72877289
def melt(

pandas/tests/generic/test_finalize.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,7 @@
154154
),
155155
marks=not_implemented_mark,
156156
),
157-
pytest.param(
158-
(pd.DataFrame, frame_data, operator.methodcaller("pivot", columns="A")),
159-
marks=not_implemented_mark,
160-
),
157+
(pd.DataFrame, frame_data, operator.methodcaller("pivot", columns="A")),
161158
pytest.param(
162159
(
163160
pd.DataFrame,
@@ -171,10 +168,7 @@
171168
(pd.DataFrame, frame_data, operator.methodcaller("explode", "A")),
172169
marks=not_implemented_mark,
173170
),
174-
pytest.param(
175-
(pd.DataFrame, frame_mi_data, operator.methodcaller("unstack")),
176-
marks=not_implemented_mark,
177-
),
171+
(pd.DataFrame, frame_mi_data, operator.methodcaller("unstack")),
178172
pytest.param(
179173
(
180174
pd.DataFrame,

0 commit comments

Comments
 (0)