diff --git a/pandas/tests/indexing/multiindex/test_loc.py b/pandas/tests/indexing/multiindex/test_loc.py index 104fa2da7a67e..cf2d27c6f580c 100644 --- a/pandas/tests/indexing/multiindex/test_loc.py +++ b/pandas/tests/indexing/multiindex/test_loc.py @@ -912,3 +912,14 @@ def test_loc_keyerror_rightmost_key_missing(): df = df.set_index(["A", "B"]) with pytest.raises(KeyError, match="^1$"): df.loc[(100, 1)] +def test_loc_multiindex(): + df = DataFrame( + index=MultiIndex.from_product([list("abc"), list("de"), list("f")]), + columns=["Val"], + ) + result = df.loc[np.s_[:, "d", :]] + expected = DataFrame( + index=MultiIndex.from_product([list("abc"), list("d"), list("f")]), + columns=["Val"], + ) + tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/indexing/test_loc.py b/pandas/tests/indexing/test_loc.py index 25c0625d1d790..2f5bf30972967 100644 --- a/pandas/tests/indexing/test_loc.py +++ b/pandas/tests/indexing/test_loc.py @@ -40,6 +40,7 @@ from pandas.tests.indexing.common import Base + class TestLoc(Base): def test_loc_getitem_int(self): @@ -2857,3 +2858,7 @@ def test_loc_set_multiple_items_in_multiple_new_columns(self): ) tm.assert_frame_equal(df, expected) + + + +