@@ -726,16 +726,17 @@ def test_iloc_setitem_with_scalar_index(self, indexer, value):
726726
727727 @pytest .mark .filterwarnings ("ignore::UserWarning" )
728728 def test_iloc_mask (self ):
729- # GH 3631 , iloc with a mask (of a series) should raise
729+ # GH 60994 , iloc with a mask (of a series) should return accordingly
730730 df = DataFrame (list (range (5 )), index = list ("ABCDE" ), columns = ["a" ])
731731 mask = df .a % 2 == 0
732732 msg = "iLocation based boolean indexing cannot use an indexable as a mask"
733733 with pytest .raises (ValueError , match = msg ):
734734 df .iloc [mask ]
735+
735736 mask .index = range (len (mask ))
736- msg = "iLocation based boolean indexing on an integer type is not available"
737- with pytest . raises ( NotImplementedError , match = msg ):
738- df . iloc [ mask ]
737+ result = df . iloc [ mask ]
738+ expected = df . iloc [[ 0 , 2 , 4 ]]
739+ tm . assert_frame_equal ( result , expected )
739740
740741 # ndarray ok
741742 result = df .iloc [np .array ([True ] * len (mask ), dtype = bool )]
@@ -753,18 +754,14 @@ def test_iloc_mask(self):
753754 (None , ".iloc" ): "0b1100" ,
754755 ("index" , "" ): "0b11" ,
755756 ("index" , ".loc" ): "0b11" ,
756- ("index" , ".iloc" ): (
757- "iLocation based boolean indexing cannot use an indexable as a mask"
758- ),
757+ ("index" , ".iloc" ): "0b11" ,
759758 ("locs" , "" ): "Unalignable boolean Series provided as indexer "
760759 "(index of the boolean Series and of the indexed "
761760 "object do not match)." ,
762761 ("locs" , ".loc" ): "Unalignable boolean Series provided as indexer "
763762 "(index of the boolean Series and of the "
764763 "indexed object do not match)." ,
765- ("locs" , ".iloc" ): (
766- "iLocation based boolean indexing on an integer type is not available"
767- ),
764+ ("locs" , ".iloc" ): "0b1" ,
768765 }
769766
770767 # UserWarnings from reindex of a boolean mask
@@ -780,7 +777,10 @@ def test_iloc_mask(self):
780777 else :
781778 accessor = df
782779 answer = str (bin (accessor [mask ]["nums" ].sum ()))
783- except (ValueError , IndexingError , NotImplementedError ) as err :
780+ except (
781+ ValueError ,
782+ IndexingError ,
783+ ) as err :
784784 answer = str (err )
785785
786786 key = (
0 commit comments