Skip to content

Commit b1747d2

Browse files
committed
call finalize in DataFrame.stack
1 parent f60b85d commit b1747d2

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

pandas/core/frame.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7084,9 +7084,11 @@ def stack(self, level=-1, dropna=True):
70847084
from pandas.core.reshape.reshape import stack, stack_multiple
70857085

70867086
if isinstance(level, (tuple, list)):
7087-
return stack_multiple(self, level, dropna=dropna)
7087+
result = stack_multiple(self, level, dropna=dropna)
70887088
else:
7089-
return stack(self, level, dropna=dropna)
7089+
result = stack(self, level, dropna=dropna)
7090+
7091+
return result.__finalize__(self, method="stack")
70907092

70917093
def explode(
70927094
self, column: Union[str, Tuple], ignore_index: bool = False

pandas/tests/generic/test_finalize.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,7 @@
166166
),
167167
marks=not_implemented_mark,
168168
),
169-
pytest.param(
170-
(pd.DataFrame, frame_data, operator.methodcaller("stack")),
171-
marks=not_implemented_mark,
172-
),
169+
(pd.DataFrame, frame_data, operator.methodcaller("stack")),
173170
pytest.param(
174171
(pd.DataFrame, frame_data, operator.methodcaller("explode", "A")),
175172
marks=not_implemented_mark,

0 commit comments

Comments
 (0)