Skip to content

Commit

Permalink
comments, catch less (pandas-dev#29088)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored and Mateusz Górski committed Nov 18, 2019
1 parent 142048c commit 2b8d01f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
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

0 comments on commit 2b8d01f

Please sign in to comment.