@@ -527,9 +527,17 @@ def test_numpy_minmax_period(self):
527
527
def test_min_max_categorical (self ):
528
528
529
529
ci = pd .CategoricalIndex (list ("aabbca" ), categories = list ("cab" ), ordered = False )
530
- with pytest .raises (TypeError ):
530
+ msg = (
531
+ r"Categorical is not ordered for operation min\n"
532
+ r"you can use .as_ordered\(\) to change the Categorical to an ordered one\n"
533
+ )
534
+ with pytest .raises (TypeError , match = msg ):
531
535
ci .min ()
532
- with pytest .raises (TypeError ):
536
+ msg = (
537
+ r"Categorical is not ordered for operation max\n"
538
+ r"you can use .as_ordered\(\) to change the Categorical to an ordered one\n"
539
+ )
540
+ with pytest .raises (TypeError , match = msg ):
533
541
ci .max ()
534
542
535
543
ci = pd .CategoricalIndex (list ("aabbca" ), categories = list ("cab" ), ordered = True )
@@ -881,16 +889,20 @@ def test_all_any_params(self):
881
889
tm .assert_series_equal (s .all (level = 0 ), Series ([False , True , False ]))
882
890
tm .assert_series_equal (s .any (level = 0 ), Series ([False , True , True ]))
883
891
884
- # bool_only is not implemented with level option.
885
- with pytest .raises (NotImplementedError ):
892
+ msg = "Option bool_only is not implemented with option level"
893
+ with pytest .raises (NotImplementedError , match = msg ):
886
894
s .any (bool_only = True , level = 0 )
887
- with pytest .raises (NotImplementedError ):
895
+ with pytest .raises (NotImplementedError , match = msg ):
888
896
s .all (bool_only = True , level = 0 )
889
897
890
898
# bool_only is not implemented alone.
891
- with pytest .raises (NotImplementedError ):
899
+ # TODO GH38810 change this error message to:
900
+ # "Series.any does not implement bool_only"
901
+ msg = "Series.any does not implement numeric_only"
902
+ with pytest .raises (NotImplementedError , match = msg ):
892
903
s .any (bool_only = True )
893
- with pytest .raises (NotImplementedError ):
904
+ msg = "Series.all does not implement numeric_only."
905
+ with pytest .raises (NotImplementedError , match = msg ):
894
906
s .all (bool_only = True )
895
907
896
908
def test_all_any_boolean (self ):
@@ -1023,13 +1035,21 @@ def test_assert_idxminmax_raises(self, test_input, error_type):
1023
1035
"""
1024
1036
Cases where ``Series.argmax`` and related should raise an exception
1025
1037
"""
1026
- with pytest .raises (error_type ):
1038
+ msg = (
1039
+ "reduction operation 'argmin' not allowed for this dtype|"
1040
+ "attempt to get argmin of an empty sequence"
1041
+ )
1042
+ with pytest .raises (error_type , match = msg ):
1027
1043
test_input .idxmin ()
1028
- with pytest .raises (error_type ):
1044
+ with pytest .raises (error_type , match = msg ):
1029
1045
test_input .idxmin (skipna = False )
1030
- with pytest .raises (error_type ):
1046
+ msg = (
1047
+ "reduction operation 'argmax' not allowed for this dtype|"
1048
+ "attempt to get argmax of an empty sequence"
1049
+ )
1050
+ with pytest .raises (error_type , match = msg ):
1031
1051
test_input .idxmax ()
1032
- with pytest .raises (error_type ):
1052
+ with pytest .raises (error_type , match = msg ):
1033
1053
test_input .idxmax (skipna = False )
1034
1054
1035
1055
def test_idxminmax_with_inf (self ):
0 commit comments