Skip to content

Commit 18ab457

Browse files
timsaucerclaude
andcommitted
Add grouping sets note to DataFrame.aggregate() docstring
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4a1efcb commit 18ab457

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

python/datafusion/dataframe.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,22 @@ def aggregate(
633633
) -> DataFrame:
634634
"""Aggregates the rows of the current DataFrame.
635635
636+
By default each unique combination of the ``group_by`` columns
637+
produces one row. To get multiple levels of subtotals in a
638+
single pass, pass a
639+
:py:class:`~datafusion.expr.GroupingSet` expression
640+
(created via
641+
:py:meth:`~datafusion.expr.GroupingSet.rollup`,
642+
:py:meth:`~datafusion.expr.GroupingSet.cube`, or
643+
:py:meth:`~datafusion.expr.GroupingSet.grouping_sets`)
644+
as the ``group_by`` argument. See the
645+
:ref:`aggregation` user guide for detailed examples.
646+
636647
Args:
637-
group_by: Sequence of expressions or column names to group by.
648+
group_by: Sequence of expressions or column names to group
649+
by. A :py:class:`~datafusion.expr.GroupingSet`
650+
expression may be included to produce multiple grouping
651+
levels (rollup, cube, or explicit grouping sets).
638652
aggs: Sequence of expressions to aggregate.
639653
640654
Returns:

0 commit comments

Comments
 (0)