Skip to content

Commit 23a6684

Browse files
simonjayhawkinsjreback
authored andcommitted
TST: add test for multiindex partial indexing both axis (#27359)
1 parent 07d0488 commit 23a6684

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/indexing/multiindex/test_partial.py

+11
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,14 @@ def test_setitem_multiple_partial(self, multiindex_dataframe_random_data):
188188
expected.loc["foo"] = 0
189189
expected.loc["bar"] = 0
190190
tm.assert_series_equal(result, expected)
191+
192+
193+
def test_loc_getitem_partial_both_axis():
194+
# gh-12660
195+
iterables = [["a", "b"], [2, 1]]
196+
columns = MultiIndex.from_product(iterables, names=["col1", "col2"])
197+
rows = MultiIndex.from_product(iterables, names=["row1", "row2"])
198+
df = DataFrame(np.random.randn(4, 4), index=rows, columns=columns)
199+
expected = df.iloc[:2, 2:].droplevel("row1").droplevel("col1", axis=1)
200+
result = df.loc["a", "b"]
201+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)