@@ -250,6 +250,10 @@ def test_cummin_cummax(self, df, method):
250
250
def _check (self , df , method , expected_columns , expected_columns_numeric ):
251
251
gb = df .groupby ("group" )
252
252
253
+ # object dtypes for transformations are not implemented in Cython and
254
+ # have no Python fallback
255
+ exception = NotImplementedError if method .startswith ("cum" ) else TypeError
256
+
253
257
if method in ("min" , "max" , "cummin" , "cummax" ):
254
258
# The methods default to numeric_only=False and raise TypeError
255
259
msg = "|" .join (
@@ -258,7 +262,7 @@ def _check(self, df, method, expected_columns, expected_columns_numeric):
258
262
"function is not implemented for this dtype" ,
259
263
]
260
264
)
261
- with pytest .raises (TypeError , match = msg ):
265
+ with pytest .raises (exception , match = msg ):
262
266
getattr (gb , method )()
263
267
else :
264
268
result = getattr (gb , method )()
@@ -274,7 +278,7 @@ def _check(self, df, method, expected_columns, expected_columns_numeric):
274
278
"function is not implemented for this dtype" ,
275
279
]
276
280
)
277
- with pytest .raises (TypeError , match = msg ):
281
+ with pytest .raises (exception , match = msg ):
278
282
getattr (gb , method )(numeric_only = False )
279
283
else :
280
284
result = getattr (gb , method )(numeric_only = False )
@@ -1436,6 +1440,11 @@ def test_deprecate_numeric_only(
1436
1440
elif has_arg or kernel in ("idxmax" , "idxmin" ):
1437
1441
assert numeric_only is not True
1438
1442
# kernels that are successful on any dtype were above; this will fail
1443
+
1444
+ # object dtypes for transformations are not implemented in Cython and
1445
+ # have no Python fallback
1446
+ exception = NotImplementedError if kernel .startswith ("cum" ) else TypeError
1447
+
1439
1448
msg = "|" .join (
1440
1449
[
1441
1450
"not allowed for this dtype" ,
@@ -1447,7 +1456,7 @@ def test_deprecate_numeric_only(
1447
1456
"function is not implemented for this dtype" ,
1448
1457
]
1449
1458
)
1450
- with pytest .raises (TypeError , match = msg ):
1459
+ with pytest .raises (exception , match = msg ):
1451
1460
method (* args , ** kwargs )
1452
1461
elif not has_arg and numeric_only is not lib .no_default :
1453
1462
with pytest .raises (
0 commit comments