Dataframe
 
1.0

groupBy

Edit pageLast modified: 05 June 2025

Splits the rows of DataFrame into groups using one or several columns as grouping keys.

See column selectors for how to select the columns for this operation, groupBy transformations, groupBy aggregations, and pivot+groupBy.

df.groupBy { name }
df.groupBy { city and name.lastName }
df.groupBy { age / 10 named "ageDecade" }

Grouping columns can be created inplace:

df.groupBy { expr { name.firstName.length + name.lastName.length } named "nameLength" }

With optional moveToTop parameter you can choose whether to make a selected nested column a top-level column:

or to keep it inside a ColumnGroup:

Returns GroupBy object.