@@ -1062,25 +1062,62 @@ def test_any_all_datetimelike(self):
1062
1062
assert df .any ().all ()
1063
1063
assert not df .all ().any ()
1064
1064
1065
- def test_any_all_pyarrow_string (self ):
1065
+ def test_any_all_string_dtype (self , any_string_dtype ):
1066
1066
# GH#54591
1067
- pytest .importorskip ("pyarrow" )
1068
- ser = Series (["" , "a" ], dtype = "string[pyarrow_numpy]" )
1067
+ if (
1068
+ isinstance (any_string_dtype , pd .StringDtype )
1069
+ and any_string_dtype .na_value is pd .NA
1070
+ ):
1071
+ # the nullable string dtype currently still raise an error
1072
+ # https://github.com/pandas-dev/pandas/issues/51939
1073
+ ser = Series (["a" , "b" ], dtype = any_string_dtype )
1074
+ with pytest .raises (TypeError ):
1075
+ ser .any ()
1076
+ with pytest .raises (TypeError ):
1077
+ ser .all ()
1078
+ return
1079
+
1080
+ ser = Series (["" , "a" ], dtype = any_string_dtype )
1069
1081
assert ser .any ()
1070
1082
assert not ser .all ()
1083
+ assert ser .any (skipna = False )
1084
+ assert not ser .all (skipna = False )
1071
1085
1072
- ser = Series ([None , "a" ], dtype = "string[pyarrow_numpy]" )
1086
+ ser = Series ([np . nan , "a" ], dtype = any_string_dtype )
1073
1087
assert ser .any ()
1074
1088
assert ser .all ()
1075
- assert not ser .all (skipna = False )
1089
+ assert ser .any (skipna = False )
1090
+ assert ser .all (skipna = False ) # NaN is considered truthy
1076
1091
1077
- ser = Series ([None , "" ], dtype = "string[pyarrow_numpy]" )
1092
+ ser = Series ([np . nan , "" ], dtype = any_string_dtype )
1078
1093
assert not ser .any ()
1079
1094
assert not ser .all ()
1095
+ assert ser .any (skipna = False ) # NaN is considered truthy
1096
+ assert not ser .all (skipna = False )
1080
1097
1081
- ser = Series (["a" , "b" ], dtype = "string[pyarrow_numpy]" )
1098
+ ser = Series (["a" , "b" ], dtype = any_string_dtype )
1082
1099
assert ser .any ()
1083
1100
assert ser .all ()
1101
+ assert ser .any (skipna = False )
1102
+ assert ser .all (skipna = False )
1103
+
1104
+ ser = Series ([], dtype = any_string_dtype )
1105
+ assert not ser .any ()
1106
+ assert ser .all ()
1107
+ assert not ser .any (skipna = False )
1108
+ assert ser .all (skipna = False )
1109
+
1110
+ ser = Series (["" ], dtype = any_string_dtype )
1111
+ assert not ser .any ()
1112
+ assert not ser .all ()
1113
+ assert not ser .any (skipna = False )
1114
+ assert not ser .all (skipna = False )
1115
+
1116
+ ser = Series ([np .nan ], dtype = any_string_dtype )
1117
+ assert not ser .any ()
1118
+ assert ser .all ()
1119
+ assert ser .any (skipna = False ) # NaN is considered truthy
1120
+ assert ser .all (skipna = False ) # NaN is considered truthy
1084
1121
1085
1122
def test_timedelta64_analytics (self ):
1086
1123
# index min/max
0 commit comments