Skip to content

Commit 8475562

Browse files
committed
call finalize in DataFrame.stack
1 parent 2cb91d9 commit 8475562

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
@@ -7097,9 +7097,11 @@ def stack(self, level=-1, dropna=True):
70977097
from pandas.core.reshape.reshape import stack, stack_multiple
70987098

70997099
if isinstance(level, (tuple, list)):
7100-
return stack_multiple(self, level, dropna=dropna)
7100+
result = stack_multiple(self, level, dropna=dropna)
71017101
else:
7102-
return stack(self, level, dropna=dropna)
7102+
result = stack(self, level, dropna=dropna)
7103+
7104+
return result.__finalize__(self, method="stack")
71037105

71047106
def explode(
71057107
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)