group

fun <T, C> DataFrame<T>.group(columns: ColumnsSelector<T, C>): GroupClause<T, C>

Groups the specified columns within the DataFrame into column group.

This function does not immediately group the columns but instead selects columns to group and returns a GroupClause, which serves as an intermediate step. The GroupClause allows specifying the final destination of the selected columns using methods such as into and, that return a new DataFrame with grouped columns. Check out Grammar.

This can include column groups and nested columns.

See Selecting Columns.

For more information: See group on the documentation website.

Reverse operation: ungroup.

It is a special case of move operation.

Don't confuse this with groupBy, which groups the dataframe by the values in the selected columns!

This Group Overload

Select or express columns using the Columns Selection DSL.

This DSL is initiated by a Columns Selector lambda, which operates in the context of the Columns Selection DSL and expects you to return a SingleColumn or ColumnSet (so, a ColumnsResolver). This is an entity formed by calling any (combination) of the functions in the DSL that is or can be resolved into one or more columns.

The Columns Selection DSL allows using Extension Properties for specifying columns type- and name-safe.

Check out: Columns Selection DSL Grammar

    

See Column Selectors on the documentation website.

Examples:

df.group { columnA and columnB }.into("valueCols")
df.group { colsOf<String>() }.into { it.name.split(".").first() }

Parameters

columns

The Columns Selector used to select the columns of this DataFrame to group.


fun <T> DataFrame<T>.group(vararg columns: String): GroupClause<T, Any?>

Groups the specified columns within the DataFrame into column group.

This function does not immediately group the columns but instead selects columns to group and returns a GroupClause, which serves as an intermediate step. The GroupClause allows specifying the final destination of the selected columns using methods such as into and, that return a new DataFrame with grouped columns. Check out Grammar.

This can include column groups and nested columns.

See Selecting Columns.

For more information: See group on the documentation website.

Reverse operation: ungroup.

It is a special case of move operation.

Don't confuse this with groupBy, which groups the dataframe by the values in the selected columns!

This Group Overload

Select single or multiple columns using their names as Strings. (String API).

Example:

df.group("second").into("valueCols")
df.group("prop.A", "prop.B", "cnt.A", "cnt.B").into { it.name.split(".").first() }

Parameters

columns

The Column Names used to select the columns of this DataFrame to group.


The DataFrame representing the group corresponding to the current key values.

For more information: See groupBy on the documentation website.


fun <T> DataFrame<T>.group(vararg columns: ColumnReference<*>): GroupClause<T, Any?>
fun <T> DataFrame<T>.group(vararg columns: KProperty<*>): GroupClause<T, Any?>

Deprecated

It's recommended to migrate to the String or Extension Properties Access API https://kotlin.github.io/dataframe/apilevels.html