aggregate

abstract fun <R> aggregate(body: AggregateGroupedBody<T, R>): DataRow<T>

Aggregates this DataFrame using the provided statistics inside the AggregateDsl.

Returns a new DataRow with the aggregated values.

AggregateDsl allows you to compute statistics on the columns of this DataFrame and store the results as a new column using into.

The resulting DataRow has the same structure as the original DataFrame; instead of the groups, there are new columns of aggregated values created with into.

You can use any of DataFrame Aggregation Statistics or any custom aggregation function.

Aggregated values can be either simple values, data rows or even data frames. Including them in the result using into will lead to creating a value column, a column group, or a frame column respectively in the resulting DataRow while preserving the original structure at higher levels.

Example

df.aggregate {
// Сount rows within each group and store the result
// into a new "total" column
count() into "total"

// Compute the maximum in "age" column within each group
// and store it into a new "maxAge" column
max { age } into "maxAge"
}

Return

A new DataRow with the results of the aggregation.

Parameters

body

The aggregation logic defined using AggregateDsl.