@@ -188,15 +188,16 @@ def test_comparison_with_unknown_scalars(self):
188188
189189 def test_comparison_with_known_scalars (self ):
190190 # https://github.com/pandas-dev/pandas/issues/26504
191- # and following comparisons with scalars not in categories should raise
192- # for unequal comps, but not for equal/not equal
193- cat = Categorical ([1 , 2 , 3 , None ], categories = [1 , 2 , 3 ], ordered = True )
191+ # and following comparisons with scalars in categories with None should
192+ # be evaluated as False
194193
195- msg = ( "Cannot compare a Categorical for op __{}__ with a scalar,"
196- " which is not a category" )
194+ cat1 = Categorical ([ 1 , 2 , 3 , None ], categories = [ 1 , 2 , 3 ], ordered = True )
195+ cat2 = Categorical ([ None , 1 , 2 , 3 ], categories = [ 1 , 2 , 3 ], ordered = True )
197196
198- tm .assert_numpy_array_equal (cat <= 2 ,
199- np .array ([True , True , False , False ]))
197+ tm .assert_numpy_array_equal (cat1 <= 2 ,
198+ np .array ([True , True , False , False ]))
199+ tm .assert_numpy_array_equal (cat1 <= 2 ,
200+ np .array ([False , True , True , False ]))
200201
201202 @pytest .mark .parametrize ('data,reverse,base' , [
202203 (list ("abc" ), list ("cba" ), list ("bbb" )),
0 commit comments