From 3154f49cea98d6d7f584e3aa2663864d4fab01a3 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 18 Oct 2019 15:22:43 -0700 Subject: [PATCH] comments, catch less --- pandas/core/groupby/generic.py | 12 ++++-------- pandas/core/groupby/ops.py | 10 +++++++++- pandas/core/series.py | 1 + 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index 8191c3519a36a..a78857423e7e0 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -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) @@ -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 diff --git a/pandas/core/groupby/ops.py b/pandas/core/groupby/ops.py index e380cf5930f97..fcc646dec89d9 100644 --- a/pandas/core/groupby/ops.py +++ b/pandas/core/groupby/ops.py @@ -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): diff --git a/pandas/core/series.py b/pandas/core/series.py index 1039e9af929d4..ea48b3603623a 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -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