Skip to content

Commit f8a945b

Browse files
committed
Refactor aggregate method to directly handle expression conversion for group by and aggregation lists
1 parent 54b3c2e commit f8a945b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

python/datafusion/dataframe.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,10 @@ def aggregate(
546546
group_by_list = group_by if isinstance(group_by, list) else [group_by]
547547
aggs_list = aggs if isinstance(aggs, list) else [aggs]
548548

549-
group_by_exprs = _to_expr_list(group_by_list)
550-
aggs_exprs = _to_expr_list(aggs_list)
549+
group_by_exprs = [
550+
Expr.column(e).expr if isinstance(e, str) else e.expr for e in group_by_list
551+
]
552+
aggs_exprs = [e.expr for e in aggs_list]
551553
return DataFrame(self.df.aggregate(group_by_exprs, aggs_exprs))
552554

553555
def sort(self, *exprs: Expr | SortExpr | str) -> DataFrame:

0 commit comments

Comments
 (0)