stdOf

inline fun <T, reified R : Number?> DataColumn<T>.stdOf(skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault, noinline expression: (T) -> R): Double

Returns the standard deviation of the values that the given expression returns for each element of this DataColumn, as a Double.

The result of the expression is considered the 'input' of this operation.

All primitive number types are supported: Byte, Short, Int, Long, Float, and Double. "Mixed" Number input is supported too, as long as it consists solely of those primitive numbers; its values are then first converted to their common type using UnifiedNumberTypeOptions.PRIMITIVES_ONLY, see number unification. Big numbers (BigInteger, BigDecimal) are not supported; convert them to a primitive number type first.

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.

The resulting standard deviation is always a Double and never null. Converting Long values to Double may lose precision for very large values.

For more information about the resulting types: See "std Type Conversion" on the documentation website.

When there is nothing to compute the standard deviation of, for instance, when the input is empty or contains only null values, the result is Double.NaN. The same holds when there are no more than ddof values, so, by default, for a single value.

See also:

  • std — the standard deviation of the values in this column itself.

  • meanOf — the mean of those values.

  • The Std Operation — an overview of all std modes.

For more information: See std on the documentation website.

Example

// The standard deviation of the lengths of all first names in the "name"/"firstName" column
df.name.firstName.stdOf { it.length }

Return

The standard deviation of the values expression returns, as a Double.

Parameters

expression

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

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.

ddof

"Delta Degrees of Freedom". The divisor used in the calculation is N - ddof, where N is the number of values. The default is 1, which applies Bessel's correction and computes the unbiased sample standard deviation (as in R). Use 0 for the population standard deviation (as in Numpy).


inline fun <T, reified R : Number?> DataFrame<T>.stdOf(skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault, crossinline expression: RowExpression<T, R>): Double

Returns the standard deviation of the values that the given expression returns for each row of this DataFrame, as a Double.

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.

All primitive number types are supported: Byte, Short, Int, Long, Float, and Double. "Mixed" Number input is supported too, as long as it consists solely of those primitive numbers; its values are then first converted to their common type using UnifiedNumberTypeOptions.PRIMITIVES_ONLY, see number unification. Big numbers (BigInteger, BigDecimal) are not supported; convert them to a primitive number type first.

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.

The resulting standard deviation is always a Double and never null. Converting Long values to Double may lose precision for very large values.

For more information about the resulting types: See "std Type Conversion" on the documentation website.

When there is nothing to compute the standard deviation of, for instance, when the input is empty or contains only null values, the result is Double.NaN. The same holds when there are no more than ddof values, so, by default, for a single value.

See also:

  • std{ columns } — a single standard deviation of all values in the selected columns.

  • meanOf — the mean of the values of the given expression.

  • The Std Operation — an overview of all std modes.

For more information: See std on the documentation website.

Example

// The standard deviation of the weight-to-age ratios of all rows
df.stdOf { (weight ?: 0) / age }

Return

The standard deviation of the values expression returns, as a Double.

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.

ddof

"Delta Degrees of Freedom". The divisor used in the calculation is N - ddof, where N is the number of values. The default is 1, which applies Bessel's correction and computes the unbiased sample standard deviation (as in R). Use 0 for the population standard deviation (as in Numpy).

expression

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


inline fun <T, reified R : Number?> Grouped<T>.stdOf(name: String? = null, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault, crossinline expression: RowExpression<T, R>): DataFrame<T>

Aggregates this GroupBy by computing the standard deviation 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 standard deviation per group, named name (or "std" 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.

All primitive number types are supported: Byte, Short, Int, Long, Float, and Double. "Mixed" Number input is supported too, as long as it consists solely of those primitive numbers; its values are then first converted to their common type using UnifiedNumberTypeOptions.PRIMITIVES_ONLY, see number unification. Big numbers (BigInteger, BigDecimal) are not supported; convert them to a primitive number type first.

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.

The resulting standard deviation is always a Double and never null. Converting Long values to Double may lose precision for very large values.

For more information about the resulting types: See "std Type Conversion" on the documentation website.

Result cells for which there is nothing to compute the standard deviation of (for instance, because the input was empty or contained only null values) simply become Double.NaN. The same holds when there are no more than ddof values, so, by default, for a single value.

See also:

  • std — a single standard deviation of all values in the selected columns, per group.

  • meanOf — the mean of those values, per group.

  • aggregate — the general way to aggregate groups.

  • The Std Operation — an overview of all std 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 standard deviation of the weight-to-age ratios, in a column called "stdRatio"
df.groupBy { city }.stdOf("stdRatio") { (weight ?: 0) / age }

Return

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

Parameters

name

The name of the resulting column. If null (the default), "std" 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.

ddof

"Delta Degrees of Freedom". The divisor used in the calculation is N - ddof, where N is the number of values. The default is 1, which applies Bessel's correction and computes the unbiased sample standard deviation (as in R). Use 0 for the population standard deviation (as in Numpy).

expression

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


inline fun <T, reified R : Number?> Pivot<T>.stdOf(skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault, crossinline expression: RowExpression<T, R>): DataRow<T>

Aggregates this Pivot by computing the standard deviation of the values that the given expression returns for each row, per group.

Returns a single DataRow with the pivot keys as (nested) columns, containing the standard deviation 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.

All primitive number types are supported: Byte, Short, Int, Long, Float, and Double. "Mixed" Number input is supported too, as long as it consists solely of those primitive numbers; its values are then first converted to their common type using UnifiedNumberTypeOptions.PRIMITIVES_ONLY, see number unification. Big numbers (BigInteger, BigDecimal) are not supported; convert them to a primitive number type first.

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.

The resulting standard deviation is always a Double and never null. Converting Long values to Double may lose precision for very large values.

For more information about the resulting types: See "std Type Conversion" on the documentation website.

Result cells for which there is nothing to compute the standard deviation of (for instance, because the input was empty or contained only null values) simply become Double.NaN. The same holds when there are no more than ddof values, so, by default, for a single 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 standard deviation of the weight-to-age ratios
df.pivot { city }.stdOf { (weight ?: 0) / age }

Return

A single DataRow with, per pivot group, the standard deviation 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.

ddof

"Delta Degrees of Freedom". The divisor used in the calculation is N - ddof, where N is the number of values. The default is 1, which applies Bessel's correction and computes the unbiased sample standard deviation (as in R). Use 0 for the population standard deviation (as in Numpy).

expression

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


inline fun <T, reified R : Number?> PivotGroupBy<T>.stdOf(skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault, crossinline expression: RowExpression<T, R>): DataFrame<T>

Aggregates this PivotGroupBy by computing the standard deviation of the values that the given expression returns for each row, per group.

Returns a DataFrame where each cell contains the standard deviation 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.

All primitive number types are supported: Byte, Short, Int, Long, Float, and Double. "Mixed" Number input is supported too, as long as it consists solely of those primitive numbers; its values are then first converted to their common type using UnifiedNumberTypeOptions.PRIMITIVES_ONLY, see number unification. Big numbers (BigInteger, BigDecimal) are not supported; convert them to a primitive number type first.

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.

The resulting standard deviation is always a Double and never null. Converting Long values to Double may lose precision for very large values.

For more information about the resulting types: See "std Type Conversion" on the documentation website.

Result cells for which there exists a group, but there is nothing to compute the standard deviation of (for instance, because the group was empty or contained only null values) simply become Double.NaN. The same holds when there are no more than ddof values, so, by default, for a single value.

For empty pivot intersections, null or the set default is used.

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 standard deviation of the weight-to-age ratios
df.pivot { city }.groupBy { name.lastName }.stdOf { (weight ?: 0) / age }

Return

A DataFrame with, per group, the standard deviation 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.

ddof

"Delta Degrees of Freedom". The divisor used in the calculation is N - ddof, where N is the number of values. The default is 1, which applies Bessel's correction and computes the unbiased sample standard deviation (as in R). Use 0 for the population standard deviation (as in Numpy).

expression

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