8000 Prevent Unlimited Agg Recursion with Duplicate Col Names by WillAyd · Pull Request #21066 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

Prevent Unlimited Agg Recursion with Duplicate Col Names #21066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 17, 2018
Prev Previous commit
Next Next commit
Prevented unlimited recursive aggregation
  • Loading branch information
WillAyd committed May 15, 2018
commit ee782642e1626c3f15b94c3aa12c30f9119ab365
5 changes: 2 additions & 3 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,9 +590,9 @@ def _aggregate_multiple_funcs(self, arg, _level, _axis):

# multiples
else:
for col in obj:
for index, col in enumerate(obj):
try:
colg = self._gotitem(col, ndim=1, subset=obj[col])
colg = self._gotitem(col, ndim=1, subset=obj.iloc[:, [index]])
results.append(colg.aggregate(arg))
keys.append(col)
except (TypeError, DataError):
Expand Down Expand Up @@ -675,7 +675,6 @@ def _gotitem(self, key, ndim, subset=None):
subset : object, default None
subset to act on
"""

# create a new object to prevent aliasing
if subset is None:
subset = self.obj
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -5748,7 +5748,7 @@ def _gotitem(self, key, ndim, subset=None):
subset = self

# TODO: _shallow_copy(subset)?
return self[key]
return subset[key]

_agg_doc = dedent("""
The aggregation operations are always performed over an axis, either the
Expand Down
0