File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 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):
53925392 expected = [1 ]
53935393 self .assertEqual (result , expected )
53945394
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+
53955412
53965413class TestSeriesNoneCoercion (tm .TestCase ):
53975414 EXPECTED_RESULTS = [
You can’t perform that action at this time.
0 commit comments