minOfOrNull
Returns the minimum of the values that the given selector returns for each element of this DataColumn, 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
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 minOfOrNull with minByOrNull, which returns the element the minimum selector value belongs to instead of that value.
See also:
minOf— throws instead of returningnullfor a column with nothing to compare.maxOfOrNull— the mirror operation.The Min Operation— an overview of allminmodes.
For more information: See "min / max" on the documentation website.
Example
// The length of the shortest first name in the "name"/"firstName" column,
// or `null` if the column is empty
df.name.firstName.minOfOrNull { it.length }Return
The minimum of the values selector returns, 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 minimum of the values that the given expression returns for each row of this DataFrame, 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
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 minOfOrNull with minByOrNull, which returns the row the minimum expression value belongs to instead of that value.
See also:
minOf— throws instead of returningnullwhen there's nothing to compare.minOrNull— a single minimum of all values in the selected columns.maxOfOrNull— the mirror operation.The Min Operation— an overview of allminmodes.
For more information: See "min / max" on the documentation website.
Example
// The smallest weight-to-age ratio of all rows,
// or `null` if this dataframe is empty
df.minOfOrNull { (weight ?: 0) / age }Return
The minimum of the values expression returns, or null if there are no values to compare.
Parameters
The RowExpression to compute the value to compare for each row.