@@ -323,9 +323,6 @@ def agg_or_apply_list_like(
323
323
324
324
is_groupby = isinstance (obj , (DataFrameGroupBy , SeriesGroupBy ))
325
325
326
- is_ser_or_df = isinstance (obj , (ABCDataFrame , ABCSeries ))
327
- this_args = [self .axis , * self .args ] if is_ser_or_df else self .args
328
-
329
326
context_manager : ContextManager
330
327
if is_groupby :
331
328
# When as_index=False, we combine all results using indices
@@ -344,7 +341,8 @@ def include_axis(colg) -> bool:
344
341
if selected_obj .ndim == 1 :
345
342
for a in func :
346
343
colg = obj ._gotitem (selected_obj .name , ndim = 1 , subset = selected_obj )
347
- new_res = getattr (colg , op_name )(a , * this_args , ** kwargs )
344
+ args = [self .axis , * self .args ] if include_axis (colg ) else self .args
345
+ new_res = getattr (colg , op_name )(a , * args , ** kwargs )
348
346
results .append (new_res )
349
347
350
348
# make sure we find a good name
@@ -355,7 +353,8 @@ def include_axis(colg) -> bool:
355
353
indices = []
356
354
for index , col in enumerate (selected_obj ):
357
355
colg = obj ._gotitem (col , ndim = 1 , subset = selected_obj .iloc [:, index ])
358
- new_res = getattr (colg , op_name )(func , * this_args , ** kwargs )
356
+ args = [self .axis , * self .args ] if include_axis (colg ) else self .args
357
+ new_res = getattr (colg , op_name )(func , * args , ** kwargs )
359
358
results .append (new_res )
360
359
indices .append (index )
361
360
keys = selected_obj .columns .take (indices )
0 commit comments