maxOf
Returns the maximum of the values that the given selector returns for each element of this DataColumn.
The result of the expression is considered the 'input' of this operation.
Only self-comparable values are supported: values of a type T : Comparable<T> that are mutually comparable (like strings, primitive numbers, or dates). This includes all primitive number types, but no mix of different number types, which would result in a ClassCastException.
null values in the input are always ignored.
If the input contains values, the result will be NaNNaN, unless skipNaN is set to true.
Throws a NoSuchElementException when there is nothing left to compare, for instance when the input is empty or contains only null (or, if skipNaN is true, only null and ) values.NaN
The result has the same type as the input values (minus nullability, if the input values were nullable).
For more information about the resulting types: See "min / max Type Conversion" on the documentation website.
Don't confuse maxOf with maxBy, which returns the element the maximum selector value belongs to instead of that value.
See also:
maxOfOrNull— returnsnullinstead of throwing for a column with nothing to compare.minOf— the mirror operation.The Max Operation— an overview of allmaxmodes.
For more information: See "min / max" on the documentation website.
Example
// The length of the longest first name in the "name"/"firstName" column
df.name.firstName.maxOf { it.length }Return
The maximum of the values selector returns.
Parameters
A function that returns the value to compare for each element of this column.
Throws
if there are no values to compare.
Returns the maximum of the values that the given expression returns for each row of this DataFrame.
The given RowExpression is evaluated for each row of the dataframe. The row is both the receiver and the argument (it) of the expression, so the values in it can be accessed directly.
For more information: See RowExpression on the documentation website.
The result of the expression is considered the 'input' of this operation.
Only self-comparable values are supported: values of a type T : Comparable<T> that are mutually comparable (like strings, primitive numbers, or dates). This includes all primitive number types, but no mix of different number types, which would result in a ClassCastException.
null values in the input are always ignored.
If the input contains values, the result will be NaNNaN, unless skipNaN is set to true.
Throws a NoSuchElementException when there is nothing left to compare, for instance when the input is empty or contains only null (or, if skipNaN is true, only null and ) values.NaN
The result has the same type as the input values (minus nullability, if the input values were nullable).
For more information about the resulting types: See "min / max Type Conversion" on the documentation website.
Don't confuse maxOf with maxBy, which returns the row the maximum expression value belongs to instead of that value.
See also:
maxOfOrNull— returnsnullinstead of throwing when there's nothing to compare.max— a single maximum of all values in the selected columns.minOf— the mirror operation.The Max Operation— an overview of allmaxmodes.
For more information: See "min / max" on the documentation website.
Example
// The largest weight-to-age ratio of all rows
df.maxOf { (weight ?: 0) / age }Return
The maximum of the values expression returns.
Parameters
The RowExpression to compute the value to compare for each row.
Throws
if there are no values to compare.
Aggregates this GroupBy by computing the maximum of the values that the given expression returns for each row of a group.
Returns a new DataFrame with one row per group, containing the group key columns and a single column with the maximum per group, named name (or "max" if name is null).
The given RowExpression is evaluated for each row of the dataframe. The row is both the receiver and the argument (it) of the expression, so the values in it can be accessed directly.
For more information: See RowExpression on the documentation website.
The result of the expression is considered the 'input' of this operation.
Only self-comparable values are supported: values of a type T : Comparable<T> that are mutually comparable (like strings, primitive numbers, or dates). This includes all primitive number types, but no mix of different number types, which would result in a ClassCastException.
null values in the input are always ignored.
If the input contains values, the result will be NaNNaN, unless skipNaN is set to true.
Result cells for which there is nothing left to compare (for instance, because the input was empty or contained only null values) simply become null.
For more information about the resulting types: See "min / max Type Conversion" on the documentation website.
Don't confuse maxOf with maxBy, which returns the row of each group for which the expression returns the maximum value, instead of that value.
See also:
max— a single maximum of all values in the selected columns, per group.minOf— the mirror operation.aggregate— the general way to aggregate groups.The Max Operation— an overview of allmaxmodes.
For more information: See "groupBy statistics" on the documentation website., and See "GroupBy Aggregation Statistics" on the documentation website.
Example
// For each city, the largest weight-to-age ratio, in a column called "maxRatio"
df.groupBy { city }.maxOf("maxRatio") { (weight ?: 0) / age }Return
A new DataFrame with the group keys and a single maximum per group.
Parameters
The name of the resulting column. If null (the default), "max" is used. This name needs to be unique, else a DuplicateColumnPathInsertException is thrown.
The RowExpression to compute the value to compare for each row.
Aggregates this Pivot by computing the maximum of the values that the given rowExpression returns for each row, per group.
Returns a single DataRow with the pivot keys as (nested) columns, containing the maximum of the expression's results for the rows of the corresponding group.
The given RowExpression is evaluated for each row of the dataframe. The row is both the receiver and the argument (it) of the expression, so the values in it can be accessed directly.
For more information: See RowExpression on the documentation website.
The result of the expression is considered the 'input' of this operation.
Only self-comparable values are supported: values of a type T : Comparable<T> that are mutually comparable (like strings, primitive numbers, or dates). This includes all primitive number types, but no mix of different number types, which would result in a ClassCastException.
null values in the input are always ignored.
If the input contains values, the result will be NaNNaN, unless skipNaN is set to true.
Result cells for which there is nothing left to compare (for instance, because the input was empty or contained only null values) simply become null.
For more information about the resulting types: See "min / max Type Conversion" on the documentation website.
Don't confuse maxOf with maxBy, which returns the first row of each group for which the expression returns the maximum value, instead of that value.
Check out the .Pivot Grammar
See also:
max{ columns }— a single maximum of all values in the selected columns, per group.minOf— the mirror operation.Pivot aggregation— all other ways to aggregate aPivot.The Max Operation— an overview of allmaxmodes.
For more information: See "pivot statistics" on the documentation website., and See "Pivot Aggregation statistics" on the documentation website.
Example
// For each city, the largest weight-to-age ratio
df.pivot { city }.maxOf { (weight ?: 0) / age }Return
A single DataRow with, per pivot group, the maximum of the expression's results.
Parameters
The RowExpression to evaluate for each row.
Aggregates this PivotGroupBy by computing the maximum of the values that the given rowExpression returns for each row, per group.
Returns a DataFrame where each cell contains the maximum of the expression's results for the rows of the group corresponding to that pivot key (column) and groupBy key (row).
The given RowExpression is evaluated for each row of the dataframe. The row is both the receiver and the argument (it) of the expression, so the values in it can be accessed directly.
For more information: See RowExpression on the documentation website.
The result of the expression is considered the 'input' of this operation.
Only self-comparable values are supported: values of a type T : Comparable<T> that are mutually comparable (like strings, primitive numbers, or dates). This includes all primitive number types, but no mix of different number types, which would result in a ClassCastException.
null values in the input are always ignored.
If the input contains values, the result will be NaNNaN, unless skipNaN is set to true.
Result cells for which there exists a group, but there is nothing left to compare (for instance, because the group was empty or contained only null values) simply become null.
For more information about the resulting types: See "min / max Type Conversion" on the documentation website.
For empty pivot intersections, null or the set default is used.
Don't confuse maxOf with maxBy, which returns the first row of each group for which the expression returns the maximum value, instead of that value.
Check out the .PivotGroupBy Grammar
See also:
max{ columns }— a single maximum of all values in the selected columns, per group.minOf— the mirror operation.PivotGroupBy aggregation— all other ways to aggregate aPivotGroupBy.The Max Operation— an overview of allmaxmodes.
For more information: See "pivot statistics" on the documentation website., and See "Pivot Aggregation statistics" on the documentation website.
Example
// Per city and last name, the largest weight-to-age ratio
df.pivot { city }.groupBy { name.lastName }.maxOf { (weight ?: 0) / age }Return
A DataFrame with, per group, the maximum of the expression's results.
Parameters
The RowExpression to evaluate for each row.