Skip to content

Commit

Permalink
CLN: Remove unnecessary iterators (#59297)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke authored Jul 24, 2024
1 parent dca602b commit 1500b52
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,20 +486,14 @@ def compute_dict_like(
cols = df[key]

if cols.ndim == 1:
series_list = [obj._gotitem(key, ndim=1, subset=cols)]
series = obj._gotitem(key, ndim=1, subset=cols)
results.append(getattr(series, op_name)(how, **kwargs))
keys.append(key)
else:
series_list = []
for index in range(cols.shape[1]):
col = cols.iloc[:, index]

for _, col in cols.items():
series = obj._gotitem(key, ndim=1, subset=col)
series_list.append(series)

for series in series_list:
result = getattr(series, op_name)(how, **kwargs)
results.append(result)
keys.append(key)

results.append(getattr(series, op_name)(how, **kwargs))
keys.append(key)
else:
results = [
getattr(obj._gotitem(key, ndim=1), op_name)(how, **kwargs)
Expand Down

0 comments on commit 1500b52

Please sign in to comment.