@@ -28,7 +28,8 @@ def df(self):
2828 "group" : [1 , 1 , 2 ],
2929 "int" : [1 , 2 , 3 ],
3030 "float" : [4.0 , 5.0 , 6.0 ],
31- "string" : Series (["a" , "b" , "c" ], dtype = object ),
31+ "string" : Series (["a" , "b" , "c" ], dtype = "str" ),
32+ "object" : Series (["a" , "b" , "c" ], dtype = object ),
3233 "category_string" : Series (list ("abc" )).astype ("category" ),
3334 "category_int" : [7 , 8 , 9 ],
3435 "datetime" : date_range ("20130101" , periods = 3 ),
@@ -40,6 +41,7 @@ def df(self):
4041 "int" ,
4142 "float" ,
4243 "string" ,
44+ "object" ,
4345 "category_string" ,
4446 "category_int" ,
4547 "datetime" ,
@@ -112,6 +114,7 @@ def test_first_last(self, df, method):
112114 "int" ,
113115 "float" ,
114116 "string" ,
117+ "object" ,
115118 "category_string" ,
116119 "category_int" ,
117120 "datetime" ,
@@ -159,7 +162,9 @@ def _check(self, df, method, expected_columns, expected_columns_numeric):
159162
160163 # object dtypes for transformations are not implemented in Cython and
161164 # have no Python fallback
162- exception = NotImplementedError if method .startswith ("cum" ) else TypeError
165+ exception = (
166+ (NotImplementedError , TypeError ) if method .startswith ("cum" ) else TypeError
167+ )
163168
164169 if method in ("min" , "max" , "cummin" , "cummax" , "cumsum" , "cumprod" ):
165170 # The methods default to numeric_only=False and raise TypeError
@@ -170,6 +175,7 @@ def _check(self, df, method, expected_columns, expected_columns_numeric):
170175 re .escape (f"agg function failed [how->{ method } ,dtype->object]" ),
171176 # cumsum/cummin/cummax/cumprod
172177 "function is not implemented for this dtype" ,
178+ f"dtype 'str' does not support operation '{ method } '" ,
173179 ]
174180 )
175181 with pytest .raises (exception , match = msg ):
0 commit comments