4
4
from collections import defaultdict
5
5
from functools import partial
6
6
import inspect
7
- import re
8
7
from typing import (
9
8
TYPE_CHECKING ,
10
9
Any ,
@@ -339,12 +338,6 @@ def agg_list_like(self) -> DataFrame | Series:
339
338
keys = []
340
339
failed_names = []
341
340
342
- depr_nuisance_columns_msg = (
343
- "{} did not aggregate successfully. If any error is "
344
- "raised this will raise in a future version of pandas. "
345
- "Drop these columns/ops to avoid this warning."
346
- )
347
-
348
341
# degenerate case
349
342
if selected_obj .ndim == 1 :
350
343
for a in arg :
@@ -367,24 +360,7 @@ def agg_list_like(self) -> DataFrame | Series:
367
360
for index , col in enumerate (selected_obj ):
368
361
colg = obj ._gotitem (col , ndim = 1 , subset = selected_obj .iloc [:, index ])
369
362
try :
370
- # Capture and suppress any warnings emitted by us in the call
371
- # to agg below, but pass through any warnings that were
372
- # generated otherwise.
373
- with warnings .catch_warnings (record = True ) as record :
374
- new_res = colg .aggregate (arg )
375
- if len (record ) > 0 :
376
- match = re .compile (depr_nuisance_columns_msg .format (".*" ))
377
- for warning in record :
378
- if re .match (match , str (warning .message )):
379
- failed_names .append (col )
380
- else :
381
- warnings .warn_explicit (
382
- message = warning .message ,
383
- category = warning .category ,
384
- filename = warning .filename ,
385
- lineno = warning .lineno ,
386
- )
387
-
363
+ new_res = colg .aggregate (arg )
388
364
except (TypeError , DataError ):
389
365
failed_names .append (col )
390
366
except ValueError as err :
@@ -412,7 +388,9 @@ def agg_list_like(self) -> DataFrame | Series:
412
388
413
389
if len (failed_names ) > 0 :
414
390
warnings .warn (
415
- depr_nuisance_columns_msg .format (failed_names ),
391
+ f"{ failed_names } did not aggregate successfully. If any error is "
392
+ "raised this will raise in a future version of pandas. "
393
+ "Drop these columns/ops to avoid this warning." ,
416
394
FutureWarning ,
417
395
stacklevel = find_stack_level (),
418
396
)
0 commit comments