From 3ac786e4bfed04e4d8fac672da12d6a9a75b391f Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Fri, 12 Jul 2019 16:20:37 +0100 Subject: [PATCH] TST: add test for multiindex partial indexing both axis --- pandas/tests/indexing/multiindex/test_partial.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pandas/tests/indexing/multiindex/test_partial.py b/pandas/tests/indexing/multiindex/test_partial.py index 3c65f1b8abddb..b1519d82e1aa7 100644 --- a/pandas/tests/indexing/multiindex/test_partial.py +++ b/pandas/tests/indexing/multiindex/test_partial.py @@ -188,3 +188,14 @@ def test_setitem_multiple_partial(self, multiindex_dataframe_random_data): expected.loc["foo"] = 0 expected.loc["bar"] = 0 tm.assert_series_equal(result, expected) + + +def test_loc_getitem_partial_both_axis(): + # gh-12660 + iterables = [["a", "b"], [2, 1]] + columns = MultiIndex.from_product(iterables, names=["col1", "col2"]) + rows = MultiIndex.from_product(iterables, names=["row1", "row2"]) + df = DataFrame(np.random.randn(4, 4), index=rows, columns=columns) + expected = df.iloc[:2, 2:].droplevel("row1").droplevel("col1", axis=1) + result = df.loc["a", "b"] + tm.assert_frame_equal(result, expected)