@@ -1091,25 +1091,62 @@ def test_any_all_datetimelike(self):
1091
1091
assert df .any ().all ()
1092
1092
assert not df .all ().any ()
1093
1093
1094
- def test_any_all_pyarrow_string (self ):
1094
+ def test_any_all_string_dtype (self , any_string_dtype ):
1095
1095
# GH#54591
1096
- pytest .importorskip ("pyarrow" )
1097
- ser = Series (["" , "a" ], dtype = "string[pyarrow_numpy]" )
1096
+ if (
1097
+ isinstance (any_string_dtype , pd .StringDtype )
1098
+ and any_string_dtype .na_value is pd .NA
1099
+ ):
1100
+ # the nullable string dtype currently still raise an error
1101
+ # https://github.com/pandas-dev/pandas/issues/51939
1102
+ ser = Series (["a" , "b" ], dtype = any_string_dtype )
1103
+ with pytest .raises (TypeError ):
1104
+ ser .any ()
1105
+ with pytest .raises (TypeError ):
1106
+ ser .all ()
1107
+ return
1108
+
1109
+ ser = Series (["" , "a" ], dtype = any_string_dtype )
1098
1110
assert ser .any ()
1099
1111
assert not ser .all ()
1112
+ assert ser .any (skipna = False )
1113
+ assert not ser .all (skipna = False )
1100
1114
1101
- ser = Series ([None , "a" ], dtype = "string[pyarrow_numpy]" )
1115
+ ser = Series ([np . nan , "a" ], dtype = any_string_dtype )
1102
1116
assert ser .any ()
1103
1117
assert ser .all ()
1104
- assert not ser .all (skipna = False )
1118
+ assert ser .any (skipna = False )
1119
+ assert ser .all (skipna = False ) # NaN is considered truthy
1105
1120
1106
- ser = Series ([None , "" ], dtype = "string[pyarrow_numpy]" )
1121
+ ser = Series ([np . nan , "" ], dtype = any_string_dtype )
1107
1122
assert not ser .any ()
1108
1123
assert not ser .all ()
1124
+ assert ser .any (skipna = False ) # NaN is considered truthy
1125
+ assert not ser .all (skipna = False )
1109
1126
1110
- ser = Series (["a" , "b" ], dtype = "string[pyarrow_numpy]" )
1127
+ ser = Series (["a" , "b" ], dtype = any_string_dtype )
1111
1128
assert ser .any ()
1112
1129
assert ser .all ()
1130
+ assert ser .any (skipna = False )
1131
+ assert ser .all (skipna = False )
1132
+
1133
+ ser = Series ([], dtype = any_string_dtype )
1134
+ assert not ser .any ()
1135
+ assert ser .all ()
1136
+ assert not ser .any (skipna = False )
1137
+ assert ser .all (skipna = False )
1138
+
1139
+ ser = Series (["" ], dtype = any_string_dtype )
1140
+ assert not ser .any ()
1141
+ assert not ser .all ()
1142
+ assert not ser .any (skipna = False )
1143
+ assert not ser .all (skipna = False )
1144
+
1145
+ ser = Series ([np .nan ], dtype = any_string_dtype )
1146
+ assert not ser .any ()
1147
+ assert ser .all ()
1148
+ assert ser .any (skipna = False ) # NaN is considered truthy
1149
+ assert ser .all (skipna = False ) # NaN is considered truthy
1113
1150
1114
1151
def test_timedelta64_analytics (self ):
1115
1152
# index min/max
0 commit comments