Skip to content

Commit 8a40960

Browse files
authored
CLN: Simplify agg_list_like (#51396)
1 parent 10b6044 commit 8a40960

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

pandas/core/apply.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def agg_list_like(self) -> DataFrame | Series:
358358
keys = selected_obj.columns.take(indices)
359359

360360
try:
361-
concatenated = concat(results, keys=keys, axis=1, sort=False)
361+
return concat(results, keys=keys, axis=1, sort=False)
362362
except TypeError as err:
363363
# we are concatting non-NDFrame objects,
364364
# e.g. a list of scalars
@@ -370,16 +370,6 @@ def agg_list_like(self) -> DataFrame | Series:
370370
"cannot combine transform and aggregation operations"
371371
) from err
372372
return result
373-
else:
374-
# Concat uses the first index to determine the final indexing order.
375-
# The union of a shorter first index with the other indices causes
376-
# the index sorting to be different from the order of the aggregating
377-
# functions. Reindex if this is the case.
378-
index_size = concatenated.index.size
379-
full_ordered_index = next(
380-
result.index for result in results if result.index.size == index_size
381-
)
382-
return concatenated.reindex(full_ordered_index, copy=False)
383373

384374
def agg_dict_like(self) -> DataFrame | Series:
385375
"""

0 commit comments

Comments
 (0)