Skip to content

Commit 53b3dd5

Browse files
authored
TST: add test for correct behaviour of multiIndex loc with splice (#46190)
1 parent 9eb316b commit 53b3dd5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/tests/indexing/multiindex/test_loc.py

+12
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,18 @@ def test_sorted_multiindex_after_union(self):
402402
result = df.loc["2011-01-01":"2011-01-02"]
403403
tm.assert_frame_equal(result, expected)
404404

405+
def test_loc_no_second_level_index(self):
406+
# GH#43599
407+
df = DataFrame(
408+
index=MultiIndex.from_product([list("ab"), list("cd"), list("e")]),
409+
columns=["Val"],
410+
)
411+
res = df.loc[np.s_[:, "c", :]]
412+
expected = DataFrame(
413+
index=MultiIndex.from_product([list("ab"), list("e")]), columns=["Val"]
414+
)
415+
tm.assert_frame_equal(res, expected)
416+
405417

406418
@pytest.mark.parametrize(
407419
"indexer, pos",

0 commit comments

Comments
 (0)