@@ -542,6 +542,22 @@ def test_multiindex_loc_order():
542
542
exp_index = pd .MultiIndex .from_arrays ([["b" , "b" , "a" , "a" ], [1 , 2 , 1 , 2 ]])
543
543
tm .assert_index_equal (res .index , exp_index )
544
544
545
+ res = df .loc [["a" , "b" ], :]
546
+ exp_index = pd .MultiIndex .from_arrays ([["a" , "a" , "b" , "b" ], [1 , 2 , 1 , 2 ]])
547
+ tm .assert_index_equal (res .index , exp_index )
548
+
549
+ res = df .loc [(["a" , "b" ], [1 , 2 ]), :]
550
+ exp_index = pd .MultiIndex .from_arrays ([["a" , "a" , "b" , "b" ], [1 , 2 , 1 , 2 ]])
551
+ tm .assert_index_equal (res .index , exp_index )
552
+
553
+ res = df .loc [(["a" , "b" ], [2 , 1 ]), :]
554
+ exp_index = pd .MultiIndex .from_arrays ([["a" , "a" , "b" , "b" ], [2 , 1 , 2 , 1 ]])
555
+ tm .assert_index_equal (res .index , exp_index )
556
+
545
557
res = df .loc [(["b" , "a" ], [2 , 1 ]), :]
546
558
exp_index = pd .MultiIndex .from_arrays ([["b" , "b" , "a" , "a" ], [2 , 1 , 2 , 1 ]])
547
559
tm .assert_index_equal (res .index , exp_index )
560
+
561
+ res = df .loc [(["b" , "a" ], [1 , 2 ]), :]
562
+ exp_index = pd .MultiIndex .from_arrays ([["b" , "b" , "a" , "a" ], [1 , 2 , 1 , 2 ]])
563
+ tm .assert_index_equal (res .index , exp_index )
0 commit comments