Skip to content

Commit 2e31463

Browse files
jbrockmendelproost
authored andcommitted
comments, catch less (pandas-dev#29088)
1 parent 16c7d5e commit 2e31463

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

pandas/core/groupby/generic.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -1067,14 +1067,9 @@ def _aggregate_frame(self, func, *args, **kwargs):
10671067

10681068
result = OrderedDict()
10691069
if axis != obj._info_axis_number:
1070-
try:
1071-
for name, data in self:
1072-
fres = func(data, *args, **kwargs)
1073-
result[name] = self._try_cast(fres, data)
1074-
except AssertionError:
1075-
raise
1076-
except Exception:
1077-
return self._aggregate_item_by_item(func, *args, **kwargs)
1070+
for name, data in self:
1071+
fres = func(data, *args, **kwargs)
1072+
result[name] = self._try_cast(fres, data)
10781073
else:
10791074
for name in self.indices:
10801075
data = self.get_group(name, obj=obj)
@@ -1441,6 +1436,7 @@ def _choose_path(self, fast_path, slow_path, group):
14411436
raise
14421437
except Exception:
14431438
# Hard to know ex-ante what exceptions `fast_path` might raise
1439+
# TODO: no test cases get here
14441440
return path, res
14451441

14461442
# verify fast path does not change columns (and names), otherwise

pandas/core/groupby/ops.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,15 @@ def agg_series(self, obj, func):
655655
return self._aggregate_series_fast(obj, func)
656656
except AssertionError:
657657
raise
658-
except Exception:
658+
except ValueError as err:
659+
if "No result." in str(err):
660+
# raised in libreduction
661+
pass
662+
elif "Function does not reduce" in str(err):
663+
# raised in libreduction
664+
pass
665+
else:
666+
raise
659667
return self._aggregate_series_pure_python(obj, func)
660668

661669
def _aggregate_series_fast(self, obj, func):

pandas/core/series.py

+1
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,7 @@ def _set_with(self, key, value):
12881288
else:
12891289
if isinstance(key, tuple):
12901290
try:
1291+
# TODO: no test cases that get here
12911292
self._set_values(key, value)
12921293
except Exception:
12931294
pass

0 commit comments

Comments
 (0)