Skip to content

Commit d2da352

Browse files
jbrockmendelJulianWgs
authored andcommitted
REF: dont catch ValueError in aggregate_item_by_item (pandas-dev#41211)
1 parent 7171b76 commit d2da352

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

pandas/core/groupby/generic.py

+1-14
Original file line numberDiff line numberDiff line change
@@ -1207,26 +1207,13 @@ def _aggregate_item_by_item(self, func, *args, **kwargs) -> DataFrame:
12071207

12081208
obj = self._obj_with_exclusions
12091209
result: dict[int | str, NDFrame] = {}
1210-
cannot_agg = []
12111210
for item in obj:
12121211
data = obj[item]
12131212
colg = SeriesGroupBy(data, selection=item, grouper=self.grouper)
12141213

1215-
try:
1216-
result[item] = colg.aggregate(func, *args, **kwargs)
1217-
1218-
except ValueError as err:
1219-
if "Must produce aggregated value" in str(err):
1220-
# raised in _aggregate_named, handle at higher level
1221-
# see test_apply_with_mutated_index
1222-
raise
1223-
# otherwise we get here from an AttributeError in _make_wrapper
1224-
cannot_agg.append(item)
1225-
continue
1214+
result[item] = colg.aggregate(func, *args, **kwargs)
12261215

12271216
result_columns = obj.columns
1228-
if cannot_agg:
1229-
result_columns = result_columns.drop(cannot_agg)
12301217

12311218
return self.obj._constructor(result, columns=result_columns)
12321219

0 commit comments

Comments
 (0)