minOfOrNull

inline fun <T, reified R : Comparable<R & Any>?> DataColumn<T>.minOfOrNull(skipNaN: Boolean = skipNaNDefault, crossinline selector: (T) -> R): R?

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 NaN values, the result will be NaN, 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 NaN) values.

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 returning null for a column with nothing to compare.

  • maxOfOrNull — the mirror operation.

  • The Min Operation — an overview of all min modes.

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

skipNaN

If true, NaN values are ignored, just like null values. If false (the default), a NaN in the input is propagated to the result. This only has an effect on Double and Float values.

selector

A function that returns the value to compare for each element of this column.


inline fun <T, reified C : Comparable<C & Any>?> DataFrame<T>.minOfOrNull(skipNaN: Boolean = skipNaNDefault, crossinline expression: RowExpression<T, C>): C?

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 NaN values, the result will be NaN, 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 NaN) values.

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 returning null when 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 all min modes.

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

skipNaN

If true, NaN values are ignored, just like null values. If false (the default), a NaN in the input is propagated to the result. This only has an effect on Double and Float values.

expression

The RowExpression to compute the value to compare for each row.