Skip to content

Commit fac4c6c

Browse files
author
Marco Gorelli
committed
🎨 handle empty in , make whatsnewentry public-facing
1 parent 9788bf4 commit fac4c6c

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
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-6
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,7 @@ 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-
330-
if results:
331-
return DataFrame(self._wrap_aggregated_output(results), columns=columns)
332-
return DataFrame(columns=columns)
329+
return DataFrame(self._wrap_aggregated_output(results), columns=columns)
333330

334331
def _wrap_series_output(
335332
self, output: Mapping[base.OutputKey, Union[Series, np.ndarray]], index: Index
@@ -360,8 +357,10 @@ def _wrap_series_output(
360357
if len(output) > 1:
361358
result = DataFrame(indexed_output, index=index)
362359
result.columns = columns
363-
else:
360+
elif not columns.empty:
364361
result = Series(indexed_output[0], index=index, name=columns[0])
362+
else:
363+
result = DataFrame()
365364

366365
return result
367366

0 commit comments

Comments
 (0)