minOf

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

Returns the minimum 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 NaN values, the result will be NaN, 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 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 minOf with minBy, which returns the element the minimum selector value belongs to instead of that value.

See also:

  • minOfOrNull — returns null instead of throwing for a column with nothing to compare.

  • maxOf — 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
df.name.firstName.minOf { it.length }

Return

The minimum of the values selector returns.

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.

Throws

if there are no values to compare.


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

Returns the minimum 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 NaN values, the result will be NaN, 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 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 minOf with minBy, which returns the row the minimum expression value belongs to instead of that value.

See also:

  • minOfOrNull — returns null instead of throwing when there's nothing to compare.

  • min — a single minimum of all values in the selected columns.

  • maxOf — 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
df.minOf { (weight ?: 0) / age }

Return

The minimum of the values expression returns.

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.

Throws

if there are no values to compare.


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

Aggregates this GroupBy by computing the minimum 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 minimum per group, named name (or "min" 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 NaN values, the result will be NaN, 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 minOf with minBy, which returns the row of each group for which the expression returns the minimum value, instead of that value.

See also:

  • min — a single minimum of all values in the selected columns, per group.

  • maxOf — the mirror operation.

  • aggregate — the general way to aggregate groups.

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

For more information: See "groupBy statistics" on the documentation website., and See "GroupBy Aggregation Statistics" on the documentation website.

Example

// For each city, the smallest weight-to-age ratio, in a column called "minRatio"
df.groupBy { city }.minOf("minRatio") { (weight ?: 0) / age }

Return

A new DataFrame with the group keys and a single minimum per group.

Parameters

name

The name of the resulting column. If null (the default), "min" is used. This name needs to be unique, else a DuplicateColumnPathInsertException is thrown.

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.


inline fun <T, reified R : Comparable<R & Any>?> Pivot<T>.minOf(skipNaN: Boolean = skipNaNDefault, crossinline rowExpression: RowExpression<T, R>): DataRow<T>

Aggregates this Pivot by computing the minimum 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 minimum 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 NaN values, the result will be NaN, 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 minOf with minBy, which returns the first row of each group for which the expression returns the minimum value, instead of that value.

Check out the Pivot Grammar.

See also:

For more information: See "pivot statistics" on the documentation website., and See "Pivot Aggregation statistics" on the documentation website.

Example

// For each city, the smallest weight-to-age ratio
df.pivot { city }.minOf { (weight ?: 0) / age }

Return

A single DataRow with, per pivot group, the minimum of the expression's results.

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.

rowExpression

The RowExpression to evaluate for each row.


inline fun <T, reified R : Comparable<R & Any>?> PivotGroupBy<T>.minOf(skipNaN: Boolean = skipNaNDefault, crossinline rowExpression: RowExpression<T, R>): DataFrame<T>

Aggregates this PivotGroupBy by computing the minimum of the values that the given rowExpression returns for each row, per group.

Returns a DataFrame where each cell contains the minimum 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 NaN values, the result will be NaN, 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 minOf with minBy, which returns the first row of each group for which the expression returns the minimum value, instead of that value.

Check out the PivotGroupBy Grammar.

See also:

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 smallest weight-to-age ratio
df.pivot { city }.groupBy { name.lastName }.minOf { (weight ?: 0) / age }

Return

A DataFrame with, per group, the minimum of the expression's results.

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.

rowExpression

The RowExpression to evaluate for each row.