Skip to content

Commit 1500b52

Browse files
authored
CLN: Remove unnecessary iterators (#59297)
1 parent dca602b commit 1500b52

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

pandas/core/apply.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -486,20 +486,14 @@ def compute_dict_like(
486486
cols = df[key]
487487

488488
if cols.ndim == 1:
489-
series_list = [obj._gotitem(key, ndim=1, subset=cols)]
489+
series = obj._gotitem(key, ndim=1, subset=cols)
490+
results.append(getattr(series, op_name)(how, **kwargs))
491+
keys.append(key)
490492
else:
491-
series_list = []
492-
for index in range(cols.shape[1]):
493-
col = cols.iloc[:, index]
494-
493+
for _, col in cols.items():
495494
series = obj._gotitem(key, ndim=1, subset=col)
496-
series_list.append(series)
497-
498-
for series in series_list:
499-
result = getattr(series, op_name)(how, **kwargs)
500-
results.append(result)
501-
keys.append(key)
502-
495+
results.append(getattr(series, op_name)(how, **kwargs))
496+
keys.append(key)
503497
else:
504498
results = [
505499
getattr(obj._gotitem(key, ndim=1), op_name)(how, **kwargs)

0 commit comments

Comments
 (0)