Skip to content
Prev Previous commit
Next Next commit
some cleanups
  • Loading branch information
topper-123 committed Jun 6, 2023
commit 2e54b05a68a76f6ebb4bade27af0613e676254bc
4 changes: 2 additions & 2 deletions pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ def agg_or_apply_list_like(
is_groupby = isinstance(obj, (DataFrameGroupBy, SeriesGroupBy))

is_ser_or_df = isinstance(obj, (ABCDataFrame, ABCSeries))
this_args = [self.axis, *self.args] if is_ser_or_df else self.args

context_manager: ContextManager
if is_groupby:
# When as_index=False, we combine all results using indices
Expand All @@ -342,7 +344,6 @@ def include_axis(colg) -> bool:
if selected_obj.ndim == 1:
for a in func:
colg = obj._gotitem(selected_obj.name, ndim=1, subset=selected_obj)
this_args = [self.axis, *self.args] if is_ser_or_df else self.args
new_res = getattr(colg, op_name)(a, *this_args, **kwargs)
results.append(new_res)

Expand All @@ -354,7 +355,6 @@ def include_axis(colg) -> bool:
indices = []
for index, col in enumerate(selected_obj):
colg = obj._gotitem(col, ndim=1, subset=selected_obj.iloc[:, index])
this_args = [self.axis, *self.args] if is_ser_or_df else self.args
new_res = getattr(colg, op_name)(func, *this_args, **kwargs)
results.append(new_res)
indices.append(index)
Expand Down