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