Skip to content

Commit 42e9571

Browse files
author
Marco Gorelli
committed
🎨 handle empty in , make whatsnewentry public-facing
1 parent 932aac5 commit 42e9571

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

doc/source/whatsnew/v1.0.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ Groupby/resample/rolling
11321132
- Bug in :meth:`DataFrame.groupby` when using nunique on axis=1 (:issue:`30253`)
11331133
- Bug in :meth:`GroupBy.quantile` with multiple list-like q value and integer column names (:issue:`30289`)
11341134
- Bug in :meth:`GroupBy.pct_change` and :meth:`core.groupby.SeriesGroupBy.pct_change` causes ``TypeError`` when ``fill_method`` is ``None`` (:issue:`30463`)
1135-
- Bug in :meth:`SeriesGroupBy._aggregate_multiple_funcs` was resulting in aggregations being overwritten when they shared the same name (:issue:`30092`)
1135+
- Bug in :meth:`SeriesGroupBy.aggregate` was resulting in aggregations being overwritten when they shared the same name (:issue:`30092`)
11361136

11371137
Reshaping
11381138
^^^^^^^^^

pandas/core/groupby/generic.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def _aggregate_multiple_funcs(self, arg):
311311

312312
arg = zip(columns, arg)
313313

314-
results = {}
314+
results: Mapping[base.OutputKey, Union[Series, DataFrame]] = {}
315315
for idx, (name, func) in enumerate(arg):
316316
obj = self
317317

@@ -326,10 +326,8 @@ def _aggregate_multiple_funcs(self, arg):
326326
if any(isinstance(x, DataFrame) for x in results.values()):
327327
# let higher level handle
328328
return {key.label: value for key, value in results.items()}
329+
return DataFrame(self._wrap_aggregated_output(results), columns=columns)
329330

330-
if results:
331-
return DataFrame(self._wrap_aggregated_output(results), columns=columns)
332-
return DataFrame(columns=columns)
333331

334332
def _wrap_series_output(
335333
self, output: Mapping[base.OutputKey, Union[Series, np.ndarray]], index: Index
@@ -360,8 +358,10 @@ def _wrap_series_output(
360358
if len(output) > 1:
361359
result = DataFrame(indexed_output, index=index)
362360
result.columns = columns
363-
else:
361+
elif not columns.empty:
364362
result = Series(indexed_output[0], index=index, name=columns[0])
363+
else:
364+
result = DataFrame()
365365

366366
return result
367367

0 commit comments

Comments
 (0)