minByOrNull
Returns the first element of this DataColumn for which the given selector returns the minimum value, or null if there is nothing to compare.
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.
Returns null 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
Don't confuse minByOrNull with minOfOrNull, which returns the minimum selector value itself instead of the element it belongs to.
See also:
minBy— throws instead of returningnullfor a column with nothing to compare.maxByOrNull— the mirror operation.The Min Operation— an overview of allminmodes.
For more information: See minBy on the documentation website.
Example
// The shortest first name in the "name"/"firstName" column,
// or `null` if the column is empty
df.name.firstName.minByOrNull { it.length }Return
The first element for which selector returns the minimum value, or null if there are no values to compare.
Parameters
A function that returns the value to compare for each element of this column.
Returns the first row of this DataFrame for which the given expression returns the minimum value, or null if there is nothing to compare.
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.
Returns null 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
Don't confuse minByOrNull with minOfOrNull, which returns the minimum expression value itself instead of the row it belongs to.
See also:
minBy— throws instead of returningnullwhen there's nothing to compare.maxByOrNull— the mirror operation.The Min Operation— an overview of allminmodes.
For more information: See minBy on the documentation website.
Example
// The row with the smallest "age", or `null` if this dataframe is empty
df.minByOrNull { age }Return
The first DataRow for which expression returns the minimum value, or null if there are no values to compare.
Parameters
The RowExpression to compute the value to compare for each row.
Returns the first row of this DataFrame that has the smallest value in the column with the given name, or null if there is nothing to compare.
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.
Returns null 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
Don't confuse minByOrNull with minOfOrNull, which returns the minimum value a row expression returns itself, instead of the row it belongs to.
See also:
minBy— throws instead of returningnullwhen there's nothing to compare.minOrNull— returns the smallest value itself instead of the row it belongs to.maxByOrNull— the mirror operation.The Min Operation— an overview of allminmodes.
For more information: See minBy on the documentation website.
Example
// The row with the smallest "age", or `null` if this dataframe is empty
df.minByOrNull("age")Return
The first DataRow with the smallest value in the given column, or null if there are no values to compare.
Parameters
The name of the column of this DataFrame to compare the rows by.
Deprecated
It's recommended to migrate to the String or Extension Properties Access API https://kotlin.github.io/dataframe/apilevels.html