stdFor

fun <T, C : Number?> DataFrame<T>.stdFor(skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault, columns: ColumnsForAggregateSelector<T, C>): DataRow<T>

Returns the standard deviation of the values of each selected column of this DataFrame separately.

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.

The columns are selected with the ColumnsForAggregateSelectionDsl — an extension of the Columns Selection DSL which lets you rename the result of a column with into and supply a default value for columns without any values.

See Selecting Columns.

See also:

  • std() — the same, but for all suitable columns at once.

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

  • meanFor — the mean of each selected column.

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

For more information: See std on the documentation website.

Example

// A single row with the standard deviation of the "age" values and of the "weight" values
df.stdFor { age and weight }
// The same, ignoring `NaN` values, and naming the results explicitly
df.stdFor(skipNaN = true) { age into "stdAge" and (weight into "stdWeight") }

Return

A single DataRow with the standard deviation of each selected column.

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).

columns

The ColumnsForAggregateSelector used to select the columns to compute the standard deviation of.


fun <T> DataFrame<T>.stdFor(vararg columns: String, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataRow<T>

Returns the standard deviation of the values of each selected column of this DataFrame separately.

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 Selecting Columns.

See also:

  • std() — the same, but for all suitable columns at once.

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

  • meanFor — the mean of each selected column.

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

For more information: See std on the documentation website.

Example

// A single row with the standard deviation of the "age" values and of the "weight" values
df.stdFor("age", "weight")

Return

A single DataRow with the standard deviation of each selected column.

Parameters

columns

The names of the columns to compute the standard deviation of. These must be existing columns holding only primitive numbers, else an IllegalStateException or IllegalArgumentException 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).


fun <T, C : Number?> Grouped<T>.stdFor(skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault, columns: ColumnsForAggregateSelector<T, C>): DataFrame<T>

Aggregates this GroupBy by computing the standard deviation of the values of each selected column separately, per group.

Returns a new DataFrame with one row per group, containing the group key columns and a column with the standard deviation for each selected column.

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.

The columns are selected with the ColumnsForAggregateSelectionDsl — an extension of the Columns Selection DSL which lets you rename the result of a column with into and supply a default value for columns without any values.

See Selecting Columns.

See also:

  • std() — the same, but for all suitable columns at once.

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

  • meanFor — the mean of each selected column, 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 "age" values and of the "weight" values
df.groupBy { city }.stdFor { age and weight }

Return

A new DataFrame with the group keys and the standard deviation of each selected column per group.

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).

columns

The ColumnsForAggregateSelector used to select the columns to compute the standard deviation of.


fun <T> Grouped<T>.stdFor(vararg columns: String, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataFrame<T>

Aggregates this GroupBy by computing the standard deviation of the values of each selected column separately, per group.

Returns a new DataFrame with one row per group, containing the group key columns and a column with the standard deviation for each selected column.

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 Selecting Columns.

See also:

  • std() — the same, but for all suitable columns at once.

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

  • meanFor — the mean of each selected column, 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 "age" values and of the "weight" values
df.groupBy { city }.stdFor("age", "weight")

Return

A new DataFrame with the group keys and the standard deviation of each selected column per group.

Parameters

columns

The names of the columns to compute the standard deviation of. These must be existing columns holding only primitive numbers, else an IllegalStateException or IllegalArgumentException 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).


fun <T, R : Number?> Pivot<T>.stdFor(separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault, columns: ColumnsForAggregateSelector<T, R>): DataRow<T>

Aggregates this Pivot by computing the standard deviation of the values of each selected column separately, per group.

Returns a single DataRow with the pivot keys as (nested) columns, containing the standard deviation of each selected column of the corresponding group.

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.

The columns are selected with the ColumnsForAggregateSelectionDsl — an extension of the Columns Selection DSL which lets you rename the result of a column with into and supply a default value for columns without any values.

See Selecting Columns, or check out the Pivot Grammar.

See also:

  • std() — the same, but for all suitable columns at once.

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

  • Pivot aggregation — all other ways to aggregate a Pivot.

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

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 "age" values and of the "weight" values
df.pivot { city }.stdFor { age and weight }
// The same, but with the results grouped by aggregated column instead of by city
df.pivot { city }.stdFor(separate = true) { age and weight }

Return

A single DataRow with the standard deviation of each selected column per pivot group.

Parameters

separate

If false (the default), the resulting columns are indexed first by the pivot key(s) and then by the names of the aggregated columns. If true, this order is reversed: the results are grouped by aggregated column first.

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).

columns

The ColumnsForAggregateSelector used to select the columns to compute the standard deviation of.


fun <T> Pivot<T>.stdFor(vararg columns: String, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataRow<T>

Aggregates this Pivot by computing the standard deviation of the values of each selected column separately, per group.

Returns a single DataRow with the pivot keys as (nested) columns, containing the standard deviation of each selected column of the corresponding group.

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 Selecting Columns, or check out the Pivot Grammar.

See also:

  • std() — the same, but for all suitable columns at once.

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

  • Pivot aggregation — all other ways to aggregate a Pivot.

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

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 "age" values and of the "weight" values
df.pivot { city }.stdFor("age", "weight")

Return

A single DataRow with the standard deviation of each selected column per pivot group.

Parameters

columns

The names of the columns to compute the standard deviation of. These must be existing columns holding only primitive numbers, else an IllegalStateException or IllegalArgumentException is thrown.

separate

If false (the default), the resulting columns are indexed first by the pivot key(s) and then by the names of the aggregated columns. If true, this order is reversed: the results are grouped by aggregated column first.

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).


fun <T, R : Number?> PivotGroupBy<T>.stdFor(separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault, columns: ColumnsForAggregateSelector<T, R>): DataFrame<T>

Aggregates this PivotGroupBy by computing the standard deviation of the values of each selected column separately, per group.

Returns a DataFrame where each cell contains the standard deviation of each selected column of the group corresponding to that pivot key (column) and groupBy key (row).

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.

The columns are selected with the ColumnsForAggregateSelectionDsl — an extension of the Columns Selection DSL which lets you rename the result of a column with into and supply a default value for columns without any values.

See Selecting Columns, or 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 "age" values and of the "weight" values
df.pivot { city }.groupBy { name.lastName }.stdFor { age and weight }

Return

A DataFrame with the standard deviation of each selected column per group.

Parameters

separate

If false (the default), the resulting columns are indexed first by the pivot key(s) and then by the names of the aggregated columns. If true, this order is reversed: the results are grouped by aggregated column first.

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).

columns

The ColumnsForAggregateSelector used to select the columns to compute the standard deviation of.


fun <T> PivotGroupBy<T>.stdFor(vararg columns: String, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataFrame<T>

Aggregates this PivotGroupBy by computing the standard deviation of the values of each selected column separately, per group.

Returns a DataFrame where each cell contains the standard deviation of each selected column of the group corresponding to that pivot key (column) and groupBy key (row).

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.

See Selecting Columns, or 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 "age" values and of the "weight" values
df.pivot { city }.groupBy { name.lastName }.stdFor("age", "weight")

Return

A DataFrame with the standard deviation of each selected column per group.

Parameters

columns

The names of the columns to compute the standard deviation of. These must be existing columns holding only primitive numbers, else an IllegalStateException or IllegalArgumentException is thrown.

separate

If false (the default), the resulting columns are indexed first by the pivot key(s) and then by the names of the aggregated columns. If true, this order is reversed: the results are grouped by aggregated column first.

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).


fun <T, C : Number?> DataFrame<T>.stdFor(vararg columns: ColumnReference<C>, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataRow<T>
fun <T, C : Number?> DataFrame<T>.stdFor(vararg columns: KProperty<C>, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataRow<T>
fun <T, C : Number?> Grouped<T>.stdFor(vararg columns: ColumnReference<C>, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataFrame<T>
fun <T, C : Number?> Grouped<T>.stdFor(vararg columns: KProperty<C>, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataFrame<T>
fun <T, C : Number?> Pivot<T>.stdFor(vararg columns: ColumnReference<C>, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataRow<T>
fun <T, C : Number?> Pivot<T>.stdFor(vararg columns: KProperty<C>, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataRow<T>
fun <T, C : Number?> PivotGroupBy<T>.stdFor(vararg columns: ColumnReference<C>, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataFrame<T>
fun <T, C : Number?> PivotGroupBy<T>.stdFor(vararg columns: KProperty<C>, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataFrame<T>

Deprecated

It's recommended to migrate to the String or Extension Properties Access API https://kotlin.github.io/dataframe/apilevels.html