File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -275,6 +275,27 @@ def test_loc_multiindex(self):
275
275
xp = mi_int .ix [4 ]
276
276
tm .assert_frame_equal (rs , xp )
277
277
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
+
278
299
def test_loc_multiindex_indexer_none (self ):
279
300
280
301
# GH6788
You can’t perform that action at this time.
0 commit comments