max
Returns the maximum of the values in this DataColumn.
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.
See also:
maxOrNull— returnsnullinstead of throwing for a column with nothing to compare.maxOf— the maximum of the values a selector returns for each element.maxBy— the element for which a selector returns the maximum value.min— the mirror operation.The Max Operation— an overview of allmaxmodes.
For more information: See "min / max" on the documentation website.
Example
// The largest age in the "age" column
df.age.max()
// The largest weight in the "weight" column, ignoring `null` values
df.weight.max()Return
The largest value in this column.
Parameters
Throws
if there are no values to compare.
Returns the maximum of the values of each suitable column of this DataFrame separately.
All columns whose values are mutually comparable are taken into account; the other columns are simply left out of the result.
Columns inside column groups are also excluded. To include those in the maximum, flatten the DataFrame first.
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.
See also:
maxFor— the same, but for an explicit selection of columns.max{ columns }— a single maximum of all values in the selected columns.min— the mirror operation.The Max Operation— an overview of allmaxmodes.
For more information: See "min / max" on the documentation website.
Example
// A single row with the largest value of each comparable column
// ("name"/"firstName", "name"/"lastName", "age", "city", "weight", and "isHappy")
df.flatten().max()Return
A single DataRow with the maximum of each suitable column of this DataFrame.
Parameters
Returns a single maximum of all the values in the selected columns of this DataFrame.
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.
This can include column groups and nested columns.
See also:
maxOrNull— returnsnullinstead of throwing when there's nothing to compare.maxFor— the maximum of each selected column separately.maxOf— the maximum of the values a row expression returns for each row.min— the mirror operation.The Max Operation— an overview of allmaxmodes.
For more information: See "min / max" on the documentation website.
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.
For example:
Example
// The largest of all values in the "age" and "weight" columns
df.max { age and weight }Return
The largest value among all the values in the selected columns.
Parameters
The ColumnsSelector used to select the columns to compute the maximum of.
Throws
if there are no values to compare.
Returns a single maximum of all the values in the selected columns of this DataFrame.
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.
This can include column groups and nested columns.
See also:
maxOrNull— returnsnullinstead of throwing when there's nothing to compare.maxFor— the maximum of each selected column separately.maxOf— the maximum of the values a row expression returns for each row.min— the mirror operation.The Max Operation— an overview of allmaxmodes.
For more information: See "min / max" on the documentation website.
Select single or multiple columns using their names as Strings. (String API).
For example:
df.max("length", "age")
Example
// The largest of all values in the "age" and "weight" columns
df.max("age", "weight")Return
The largest value among all the values in the selected columns.
Parameters
The names of the columns to compute the maximum of. The values in these columns must be mutually comparable, else an IllegalStateException is thrown.
Throws
if there are no values to compare.
Aggregates this GroupBy by computing the maximum of the values of each suitable column separately, per group.
Returns a new DataFrame with one row per group, containing the group key columns and a column with the maximum for each suitable column. All columns whose values are mutually comparable are taken into account; the other columns are simply left out of the result.
Columns inside column groups are also excluded. To include those in the maximum, flatten the DataFrame first.
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.
See also:
maxFor— the same, but for an explicit selection of columns.max{ columns }— a single maximum of all values in the selected columns, per group.min— 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 value of each comparable column
df.groupBy { city }.max()Return
A new DataFrame with the group keys and the maximum of each suitable column per group.
Parameters
Aggregates this GroupBy by computing a single maximum of all the values in the selected columns, per group.
Returns a new DataFrame with one row per group, containing the group key columns and a single column with the maximum per group. That column is named name, or, if name is null, after the selected column if exactly one column is selected, and "max" otherwise.
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.
This can include column groups and nested columns.
See Selecting Columns.
See also:
maxFor— the maximum of each selected column separately, per group.maxOf— the maximum of the values a row expression returns for each row of a group.min— 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 of all values in the "age" and "weight" columns,
// in a column called "maxValue"
df.groupBy { city }.max("maxValue") { age and weight }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), the name of the selected column is used if exactly one column is selected, and "max" otherwise. This name needs to be unique, else a DuplicateColumnPathInsertException is thrown.
The ColumnsSelector used to select the columns to compute the maximum of.
Aggregates this GroupBy by computing a single maximum of all the values in the selected columns, per group.
Returns a new DataFrame with one row per group, containing the group key columns and a single column with the maximum per group. That column is named name, or, if name is null, after the selected column if exactly one column is selected, and "max" otherwise.
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.
This can include column groups and nested columns.
See Selecting Columns.
See also:
maxFor— the maximum of each selected column separately, per group.maxOf— the maximum of the values a row expression returns for each row of a group.min— 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 of all values in the "age" and "weight" columns,
// in a column called "maxValue"
df.groupBy { city }.max("age", "weight", name = "maxValue")Return
A new DataFrame with the group keys and a single maximum per group.
Parameters
The names of the columns to compute the maximum of. The values in these columns must be mutually comparable, else an IllegalStateException is thrown.
The name of the resulting column. If null (the default), the name of the selected column is used if exactly one column is selected, and "max" otherwise. This name needs to be unique, else a DuplicateColumnPathInsertException is thrown.
Aggregates this Pivot by computing the maximum of the values of each suitable column separately, per group.
Returns a single DataRow with the pivot keys as (nested) columns, containing the maximum of each suitable column of the corresponding group. All columns whose values are mutually comparable are taken into account; the other columns are simply left out of the result.
Columns inside column groups are also excluded. To include those in the maximum, flatten the DataFrame first.
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.
Check out the .Pivot Grammar
See also:
maxFor— the same, but for an explicit selection of columns.max{ columns }— a single maximum of all values in the selected columns, per group.min— 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 value of each comparable column
df.pivot { city }.max()Return
A single DataRow with the maximum of each suitable column per pivot group.
Parameters
If false (the default), the resulting columns are indexed first by the pivot key(s) and then by the names of the aggregated columns. If true, this order is reversed: the results are grouped by aggregated column first.
Aggregates this Pivot by computing a single maximum of all the values in the selected columns, per group.
Returns a single DataRow with the pivot keys as (nested) columns, containing the largest value among all the values in the selected columns of the corresponding group.
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.
This can include column groups and nested columns.
See Selecting Columns, or check out the .Pivot Grammar
See also:
max()— the maximum of each suitable column separately, per group.maxFor— the maximum of each selected column separately, per group.min— 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 of all values in the "age" and "weight" columns
df.pivot { city }.max { age and weight }Return
A single DataRow with, per pivot group, the largest value among all the values in the selected columns.
Parameters
The ColumnsSelector used to select the columns to compute the maximum of.
Aggregates this Pivot by computing a single maximum of all the values in the selected columns, per group.
Returns a single DataRow with the pivot keys as (nested) columns, containing the largest value among all the values in the selected columns of the corresponding group.
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.
This can include column groups and nested columns.
See Selecting Columns, or check out the .Pivot Grammar
See also:
max()— the maximum of each suitable column separately, per group.maxFor— the maximum of each selected column separately, per group.min— 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 of all values in the "age" and "weight" columns
df.pivot { city }.max("age", "weight")Return
A single DataRow with, per pivot group, the largest value among all the values in the selected columns.
Parameters
The names of the columns to compute the maximum of. The values in these columns must be mutually comparable, else an IllegalStateException is thrown.
Aggregates this PivotGroupBy by computing the maximum of the values of each suitable column separately, per group.
Returns a DataFrame where each cell contains the maximum of each suitable column of the group corresponding to that pivot key (column) and groupBy key (row). All columns whose values are mutually comparable are taken into account; the other columns are simply left out of the result.
Columns inside column groups are also excluded. To include those in the maximum, flatten the DataFrame first.
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.
Check out the .PivotGroupBy Grammar
See also:
maxFor— the same, but for an explicit selection of columns.max{ columns }— a single maximum of all values in the selected columns, per group.min— 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 value of each comparable column
df.pivot { city }.groupBy { name.lastName }.max()Return
A DataFrame with the maximum of each suitable column per group.
Parameters
If false (the default), the resulting columns are indexed first by the pivot key(s) and then by the names of the aggregated columns. If true, this order is reversed: the results are grouped by aggregated column first.
Aggregates this PivotGroupBy by computing a single maximum of all the values in the selected columns, per group.
Returns a DataFrame where each cell contains the largest value among all the values in the selected columns of the group corresponding to that pivot key (column) and groupBy key (row).
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.
This can include column groups and nested columns.
See Selecting Columns, or check out the .PivotGroupBy Grammar
See also:
max()— the maximum of each suitable column separately, per group.maxFor— the maximum of each selected column separately, per group.min— 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 of all values in the "age" and "weight" columns
df.pivot { city }.groupBy { name.lastName }.max { age and weight }Return
A DataFrame with, per group, the largest value among all the values in the selected columns.
Parameters
The ColumnsSelector used to select the columns to compute the maximum of.
Aggregates this PivotGroupBy by computing a single maximum of all the values in the selected columns, per group.
Returns a DataFrame where each cell contains the largest value among all the values in the selected columns of the group corresponding to that pivot key (column) and groupBy key (row).
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.
This can include column groups and nested columns.
See Selecting Columns, or check out the .PivotGroupBy Grammar
See also:
max()— the maximum of each suitable column separately, per group.maxFor— the maximum of each selected column separately, per group.min— 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 of all values in the "age" and "weight" columns
df.pivot { city }.groupBy { name.lastName }.max("age", "weight")Return
A DataFrame with, per group, the largest value among all the values in the selected columns.
Parameters
The names of the columns to compute the maximum of. The values in these columns must be mutually comparable, else an IllegalStateException is thrown.
Deprecated
It's recommended to migrate to the String or Extension Properties Access API https://kotlin.github.io/dataframe/apilevels.html