File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -5392,6 +5392,23 @@ def test_maybe_numeric_slice(self):
5392
5392
expected = [1 ]
5393
5393
self .assertEqual (result , expected )
5394
5394
5395
+ def test_multiindex_slice_first_level (self ):
5396
+ # GH 12697
5397
+ freq = ['a' , 'b' , 'c' , 'd' ]
5398
+ idx = pd .MultiIndex .from_product ([freq , np .arange (500 )])
5399
+ df = pd .DataFrame (list (range (2000 )), index = idx , columns = ['Test' ])
5400
+ df_slice = df .loc [pd .IndexSlice [:, 30 :70 ], :]
5401
+ result = df_slice .loc ['a' ]
5402
+ expected = pd .DataFrame (list (range (30 , 71 )),
5403
+ columns = ['Test' ],
5404
+ index = range (30 , 71 ))
5405
+ tm .assert_frame_equal (result , expected )
5406
+ result = df_slice .loc ['d' ]
5407
+ expected = pd .DataFrame (list (range (1530 , 1571 )),
5408
+ columns = ['Test' ],
5409
+ index = range (30 , 71 ))
5410
+ tm .assert_frame_equal (result , expected )
5411
+
5395
5412
5396
5413
class TestSeriesNoneCoercion (tm .TestCase ):
5397
5414
EXPECTED_RESULTS = [
You can’t perform that action at this time.
0 commit comments