Skip to content
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

CLN: Exception in _aggregate_frame #29088

Merged
merged 2 commits into from
Oct 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,14 +1067,9 @@ def _aggregate_frame(self, func, *args, **kwargs):

result = OrderedDict()
if axis != obj._info_axis_number:
try:
for name, data in self:
fres = func(data, *args, **kwargs)
result[name] = self._try_cast(fres, data)
except AssertionError:
raise
except Exception:
return self._aggregate_item_by_item(func, *args, **kwargs)
for name, data in self:
fres = func(data, *args, **kwargs)
result[name] = self._try_cast(fres, data)
else:
for name in self.indices:
data = self.get_group(name, obj=obj)
Expand Down Expand Up @@ -1441,6 +1436,7 @@ def _choose_path(self, fast_path, slow_path, group):
raise
except Exception:
# Hard to know ex-ante what exceptions `fast_path` might raise
# TODO: no test cases get here
return path, res

# verify fast path does not change columns (and names), otherwise
Expand Down
10 changes: 9 additions & 1 deletion pandas/core/groupby/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,15 @@ def agg_series(self, obj, func):
return self._aggregate_series_fast(obj, func)
except AssertionError:
raise
except Exception:
except ValueError as err:
if "No result." in str(err):
# raised in libreduction
pass
elif "Function does not reduce" in str(err):
# raised in libreduction
pass
else:
raise
return self._aggregate_series_pure_python(obj, func)

def _aggregate_series_fast(self, obj, func):
Expand Down
1 change: 1 addition & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,7 @@ def _set_with(self, key, value):
else:
if isinstance(key, tuple):
try:
# TODO: no test cases that get here
self._set_values(key, value)
except Exception:
pass
Expand Down