Skip to content

Commit d94258d

Browse files
committed
add test
1 parent 7fb30fc commit d94258d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pandas/tests/frame/test_stack_unstack.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,25 @@ def test_stack_empty_frame(dropna, future_stack):
14521452
tm.assert_series_equal(result, expected)
14531453

14541454

1455+
@pytest.mark.filterwarnings("ignore:The previous implementation of stack is deprecated")
1456+
@pytest.mark.parametrize("dropna", [True, False, lib.no_default])
1457+
def test_stack_empty_level(dropna, future_stack, int_frame):
1458+
# GH 60740
1459+
if future_stack and dropna is not lib.no_default:
1460+
with pytest.raises(ValueError, match="dropna must be unspecified"):
1461+
DataFrame(dtype=np.int64).stack(dropna=dropna, future_stack=future_stack)
1462+
else:
1463+
expected = int_frame
1464+
result = int_frame.copy().stack(
1465+
level=[], dropna=dropna, future_stack=future_stack
1466+
)
1467+
tm.assert_frame_equal(result, expected)
1468+
1469+
expected = DataFrame()
1470+
result = DataFrame().stack(level=[], dropna=dropna, future_stack=future_stack)
1471+
tm.assert_frame_equal(result, expected)
1472+
1473+
14551474
@pytest.mark.filterwarnings("ignore:The previous implementation of stack is deprecated")
14561475
@pytest.mark.parametrize("dropna", [True, False, lib.no_default])
14571476
@pytest.mark.parametrize("fill_value", [None, 0])

0 commit comments

Comments
 (0)