Skip to content

Commit d16afea

Browse files
authored
REF: Groupby length checks on values instead of keys (#43490)
1 parent 3467469 commit d16afea

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

pandas/core/groupby/generic.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def _indexed_output_to_ndframe(
369369
def _wrap_applied_output(
370370
self,
371371
data: Series,
372-
values: list[Any] | None,
372+
values: list[Any],
373373
not_indexed_same: bool = False,
374374
) -> DataFrame | Series:
375375
"""
@@ -379,7 +379,7 @@ def _wrap_applied_output(
379379
----------
380380
data : Series
381381
Input data for groupby operation.
382-
values : Optional[List[Any]]
382+
values : List[Any]
383383
Applied output for each group.
384384
not_indexed_same : bool, default False
385385
Whether the applied outputs are not indexed the same as the group axes.
@@ -388,9 +388,7 @@ def _wrap_applied_output(
388388
-------
389389
DataFrame or Series
390390
"""
391-
keys = self.grouper.group_keys_seq
392-
393-
if len(keys) == 0:
391+
if len(values) == 0:
394392
# GH #6265
395393
return self.obj._constructor(
396394
[],
@@ -1100,9 +1098,8 @@ def _aggregate_item_by_item(self, func, *args, **kwargs) -> DataFrame:
11001098
return res_df
11011099

11021100
def _wrap_applied_output(self, data, values, not_indexed_same=False):
1103-
keys = self.grouper.group_keys_seq
11041101

1105-
if len(keys) == 0:
1102+
if len(values) == 0:
11061103
result = self.obj._constructor(
11071104
index=self.grouper.result_index, columns=data.columns
11081105
)

0 commit comments

Comments
 (0)