Skip to content

Commit 7816d28

Browse files
committed
TST: partial indexing with __getitem__ and integer labels
closes pandas-dev#12416
1 parent 0e2bbcf commit 7816d28

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pandas/tests/indexing/test_multiindex.py

+21
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,27 @@ def test_loc_multiindex(self):
275275
xp = mi_int.ix[4]
276276
tm.assert_frame_equal(rs, xp)
277277

278+
def test_loc_getitem_partial_int(self):
279+
# GH 12416
280+
# with single item
281+
idx = range(2)
282+
l1 = [10, 20]
283+
l2 = ['a', 'b']
284+
df = DataFrame(index=range(2),
285+
columns=pd.MultiIndex.from_product([l1, l2]))
286+
expected = DataFrame(index=range(2),
287+
columns=l2)
288+
result = df[20]
289+
tm.assert_frame_equal(result, expected)
290+
291+
# with list
292+
df = DataFrame(index=range(2),
293+
columns=pd.MultiIndex.from_product([l1, l2]))
294+
expected = DataFrame(index=range(2),
295+
columns=pd.MultiIndex.from_product([l1[1:], l2]))
296+
result = df[[20]]
297+
tm.assert_frame_equal(result, expected)
298+
278299
def test_loc_multiindex_indexer_none(self):
279300

280301
# GH6788

0 commit comments

Comments
 (0)