@@ -742,11 +742,28 @@ def test_iloc_mask(self):
742
742
result = df .iloc [np .array ([True ] * len (mask ), dtype = bool )]
743
743
tm .assert_frame_equal (result , df )
744
744
745
- result2 = df .iloc [np .array ([True , False , True , False , True ], dtype = bool )]
745
+ result = df .iloc [np .array ([True , False , True , False , True ], dtype = bool )]
746
746
tm .assert_frame_equal (
747
- result2 , DataFrame ({"a" : [0 , 2 , 4 ]}, index = ["A" , "C" , "E" ])
747
+ result , DataFrame ({"a" : [0 , 2 , 4 ]}, index = ["A" , "C" , "E" ])
748
748
)
749
749
750
+ # series (index does not match)
751
+ msg = "Unalignable boolean Series provided as indexer"
752
+ with pytest .raises (IndexingError , match = msg ):
753
+ df .iloc [Series ([True ] * len (mask ), dtype = bool )]
754
+
755
+ df = DataFrame (list (range (5 )), columns = ["a" ])
756
+
757
+ result = df .iloc [Series ([True ] * len (mask ), dtype = bool )]
758
+ tm .assert_frame_equal (result , df )
759
+
760
+ result = df .iloc [Series ([True , False , True , False , True ], dtype = bool )]
761
+ tm .assert_frame_equal (
762
+ result , DataFrame ({"a" : [0 , 2 , 4 ]}, index = [0 , 2 , 4 ])
763
+ )
764
+
765
+ df = DataFrame (list (range (5 )), index = list ("ABCDE" ), columns = ["a" ])
766
+
750
767
# the possibilities
751
768
locs = np .arange (4 )
752
769
nums = 2 ** locs
0 commit comments