Skip to content

Commit ee78264

Browse files
committed
Prevented unlimited recursive aggregation
1 parent 11703aa commit ee78264

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

pandas/core/base.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,9 @@ def _aggregate_multiple_funcs(self, arg, _level, _axis):
590590

591591
# multiples
592592
else:
593-
for col in obj:
593+
for index, col in enumerate(obj):
594594
try:
595-
colg = self._gotitem(col, ndim=1, subset=obj[col])
595+
colg = self._gotitem(col, ndim=1, subset=obj.iloc[:, [index]])
596596
results.append(colg.aggregate(arg))
597597
keys.append(col)
598598
except (TypeError, DataError):
@@ -675,7 +675,6 @@ def _gotitem(self, key, ndim, subset=None):
675675
subset : object, default None
676676
subset to act on
677677
"""
678-
679678
# create a new object to prevent aliasing
680679
if subset is None:
681680
subset = self.obj

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5748,7 +5748,7 @@ def _gotitem(self, key, ndim, subset=None):
57485748
subset = self
57495749

57505750
# TODO: _shallow_copy(subset)?
5751-
return self[key]
5751+
return subset[key]
57525752

57535753
_agg_doc = dedent("""
57545754
The aggregation operations are always performed over an axis, either the

0 commit comments

Comments
 (0)