@@ -1091,25 +1091,62 @@ def test_any_all_datetimelike(self):
10911091 assert df .any ().all ()
10921092 assert not df .all ().any ()
10931093
1094- def test_any_all_pyarrow_string (self ):
1094+ def test_any_all_string_dtype (self , any_string_dtype ):
10951095 # 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 )
10981110 assert ser .any ()
10991111 assert not ser .all ()
1112+ assert ser .any (skipna = False )
1113+ assert not ser .all (skipna = False )
11001114
1101- ser = Series ([None , "a" ], dtype = "string[pyarrow_numpy]" )
1115+ ser = Series ([np . nan , "a" ], dtype = any_string_dtype )
11021116 assert ser .any ()
11031117 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
11051120
1106- ser = Series ([None , "" ], dtype = "string[pyarrow_numpy]" )
1121+ ser = Series ([np . nan , "" ], dtype = any_string_dtype )
11071122 assert not ser .any ()
11081123 assert not ser .all ()
1124+ assert ser .any (skipna = False ) # NaN is considered truthy
1125+ assert not ser .all (skipna = False )
11091126
1110- ser = Series (["a" , "b" ], dtype = "string[pyarrow_numpy]" )
1127+ ser = Series (["a" , "b" ], dtype = any_string_dtype )
11111128 assert ser .any ()
11121129 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
11131150
11141151 def test_timedelta64_analytics (self ):
11151152 # index min/max
0 commit comments