@@ -742,11 +742,28 @@ def test_iloc_mask(self):
742742 result = df .iloc [np .array ([True ] * len (mask ), dtype = bool )]
743743 tm .assert_frame_equal (result , df )
744744
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 )]
746746 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" ])
748748 )
749749
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+
750767 # the possibilities
751768 locs = np .arange (4 )
752769 nums = 2 ** locs
0 commit comments