Skip to content

CLN: don't catch TypeError in _aggregate_item_by_item #29177

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 5 commits into from
Oct 23, 2019
11 changes: 4 additions & 7 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,10 +1099,7 @@ def _aggregate_item_by_item(self, func, *args, **kwargs):

cast = self._transform_should_cast(func)
try:

result[item] = colg.aggregate(func, *args, **kwargs)
if cast:
result[item] = self._try_cast(result[item], data)

except ValueError as err:
if "Must produce aggregated value" in str(err):
Expand All @@ -1111,10 +1108,10 @@ def _aggregate_item_by_item(self, func, *args, **kwargs):
raise
cannot_agg.append(item)
continue
except TypeError as e:
cannot_agg.append(item)
errors = e
continue

else:
if cast:
result[item] = self._try_cast(result[item], data)

result_columns = obj.columns
if cannot_agg:
Expand Down