percentile
Returns the given percentile of the comparable values in this DataColumn.
This overload is meant for non-number self-comparable values, like strings or dates. Columns of primitive numbers use the percentile overload with a skipNaN parameter, which returns an interpolated Double.
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.
Throws a NoSuchElementException when there is nothing to compute the percentile of, for instance, when the input is empty or contains only null values.
The resulting percentile is selected from the values using quantile estimation method R3, so it has the same type as the values (minus nullability, if the values were nullable).
Currently, only the default quantile estimation methods can be used. In the future, it might become possible to choose a different one, see #1121.
For more information about the resulting types: See "percentile Type Conversion" on the documentation website.
See also:
percentileOrNull— returnsnullinstead of throwing for a column with nothing to compute the percentile of.percentileOf— the percentile of the values an expression returns for each element.percentileBy— the element at the percentile of the values a selector returns.median— the median (50th percentile) of the values in this column.The Percentile Operation— an overview of allpercentilemodes.
For more information: See percentile on the documentation website.
Example
// The first quartile of the first names in the "name"/"firstName" column (in alphabetical order)
df.name.firstName.percentile(25.0)Return
The given percentile of the values in this column.
Parameters
The percentile to compute, in the range [0.0, 100.0], like 25.0 for the first quartile, 50.0 for the median, or 75.0 for the third quartile. A percentile outside this range causes an IllegalStateException.
Throws
if there are no values to compute the percentile of.
Returns the given percentile of the numbers in this DataColumn, as a Double.
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.
Throws a NoSuchElementException when there is nothing to compute the percentile of, for instance, when the input is empty or contains only null values.
The resulting percentile is a Double, interpolated between the values using quantile estimation method R8. Converting Long values to Double may lose precision for very large values.
Currently, only the default quantile estimation methods can be used. In the future, it might become possible to choose a different one, see #1121.
Big numbers (, BigInteger) are not explicitly supported. They are self-comparable, so some overloads select a value without interpolating it, while others throw an exception at runtime. Don't rely on this; BigDecimal them to a primitive number type first.convert
For more information about the resulting types: See "percentile Type Conversion" on the documentation website.
See also:
percentileOrNull— returnsnullinstead of throwing for a column with nothing to compute the percentile of.percentileOf— the percentile of the values an expression returns for each element.percentileBy— the element at the percentile of the values a selector returns.median— the median (50th percentile) of the values in this column.The Percentile Operation— an overview of allpercentilemodes.
For more information: See percentile on the documentation website.
Example
// The first quartile of the ages in the "age" column
df.age.percentile(25.0)
// The 90th percentile of the weights in the "weight" column, ignoring `NaN` values
df.weight.percentile(90.0, skipNaN = true)Return
The given percentile of the values in this column, as a Double.
Parameters
The percentile to compute, in the range [0.0, 100.0], like 25.0 for the first quartile, 50.0 for the median, or 75.0 for the third quartile. A percentile outside this range causes an IllegalStateException.
Throws
if there are no values to compute the percentile of.
Returns the given percentile of the values of each suitable column of this DataFrame separately.
All columns whose values are mutually comparable are taken into account; the other columns are simply left out of the result.
Columns inside column groups are also excluded. To include those in the percentile, flatten the DataFrame first.
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.
For primitive numbers, the resulting percentile is a Double, interpolated between the values using quantile estimation method R8. Converting Long values to Double may lose precision for very large values. For all other self-comparable values, the resulting percentile is selected from the values using quantile estimation method R3, so it has the same type as those values.
Currently, only the default quantile estimation methods can be used. In the future, it might become possible to choose a different one, see #1121.
For more information about the resulting types: See "percentile Type Conversion" on the documentation website.
Result cells for which there is nothing to compute the percentile of (for instance, because the input was empty or contained only null values) simply become null.
See also:
percentileFor— the same, but for an explicit selection of columns.percentile(percentile) { columns }— a single percentile of all values in the selected columns.median— the median (50th percentile) of each column.The Percentile Operation— an overview of allpercentilemodes.
For more information: See percentile on the documentation website.
Example
// A single row with the first quartile of each comparable column
// ("name"/"firstName", "name"/"lastName", "age", "city", "weight", and "isHappy")
df.flatten().percentile(25.0)Return
A single DataRow with the given percentile of each suitable column of this DataFrame.
Parameters
The percentile to compute, in the range [0.0, 100.0], like 25.0 for the first quartile, 50.0 for the median, or 75.0 for the third quartile. A percentile outside this range causes an IllegalStateException.
Returns a single percentile of all the comparable values in the selected columns of this DataFrame.
This overload is meant for non-number self-comparable values, like strings or dates. For columns of primitive numbers, the percentile overload with a skipNaN parameter is used, which returns an interpolated Double.
Note: Due to a limitation in Kotlin's overload resolution (KT-76683), calling this overload with a lambda returning non-number comparable values, like strings or dates, requires either explicit type arguments, or passing the lambda inside the parentheses (see the examples below). For a lambda returning primitive numbers, the overload returning a Double is picked automatically.
From Kotlin 2.5, this limitation can be lifted by enabling eager lambda analysis (KT-51107) with the compiler option -XXLanguage:+EagerLambdaAnalysis, like kotlin { compilerOptions { freeCompilerArgs.add("-XXLanguage:+EagerLambdaAnalysis") } } in Gradle. Then, the right overload is picked for lambdas returning non-number comparable values too, without explicit type arguments. Note that this is an internal compiler option without any stability guarantees, so it is not recommended for production use yet.
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.
Throws a NoSuchElementException when there is nothing to compute the percentile of, for instance, when the input is empty or contains only null values.
The resulting percentile is selected from the values using quantile estimation method R3, so it has the same type as the values (minus nullability, if the values were nullable).
Currently, only the default quantile estimation methods can be used. In the future, it might become possible to choose a different one, see #1121.
For more information about the resulting types: See "percentile Type Conversion" on the documentation website.
See also:
percentileOrNull— returnsnullinstead of throwing when there's nothing to compute the percentile of.percentileFor— the percentile of each selected column separately.percentileOf— the percentile of the values a row expression returns for each row.median— the median (50th percentile) of all values in the selected columns.The Percentile Operation— an overview of allpercentilemodes.
For more information: See percentile on the documentation website.
Select or express columns using the Columns Selection DSL.
This DSL is initiated by a Columns Selector lambda, which operates in the context of the Columns Selection DSL and expects you to return a SingleColumn or ColumnSet (so, a ColumnsResolver). This is an entity formed by calling any (combination) of the functions in the DSL that is or can be resolved into one or more columns.
The Columns Selection DSL allows using Extension Properties for specifying columns type- and name-safe.
Check out: Columns Selection DSL Grammar
See Column Selectors on the documentation website.
Examples
// The first quartile of all first and last names in the "name" column group
df.percentile<_, String>(25.0) { name.firstName and name.lastName }
// The same, with the lambda inside the parentheses
df.percentile(25.0, { name.firstName and name.lastName })Return
The given percentile of all the values in the selected columns.
Parameters
The percentile to compute, in the range [0.0, 100.0], like 25.0 for the first quartile, 50.0 for the median, or 75.0 for the third quartile. A percentile outside this range causes an IllegalStateException.
The ColumnsSelector used to select the columns to compute the percentile of.
Throws
if there are no values to compute the percentile of.
Returns a single percentile of all the numbers in the selected columns of this DataFrame, as a Double.
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.
Throws a NoSuchElementException when there is nothing to compute the percentile of, for instance, when the input is empty or contains only null values.
The resulting percentile is a Double, interpolated between the values using quantile estimation method R8. Converting Long values to Double may lose precision for very large values.
Currently, only the default quantile estimation methods can be used. In the future, it might become possible to choose a different one, see #1121.
Big numbers (, BigInteger) are not explicitly supported. They are self-comparable, so some overloads select a value without interpolating it, while others throw an exception at runtime. Don't rely on this; BigDecimal them to a primitive number type first.convert
For more information about the resulting types: See "percentile Type Conversion" on the documentation website.
See also:
percentileOrNull— returnsnullinstead of throwing when there's nothing to compute the percentile of.percentileFor— the percentile of each selected column separately.percentileOf— the percentile of the values a row expression returns for each row.median— the median (50th percentile) of all values in the selected columns.The Percentile Operation— an overview of allpercentilemodes.
For more information: See percentile on the documentation website.
Select or express columns using the Columns Selection DSL.
This DSL is initiated by a Columns Selector lambda, which operates in the context of the Columns Selection DSL and expects you to return a SingleColumn or ColumnSet (so, a ColumnsResolver). This is an entity formed by calling any (combination) of the functions in the DSL that is or can be resolved into one or more columns.
The Columns Selection DSL allows using Extension Properties for specifying columns type- and name-safe.
Check out: Columns Selection DSL Grammar
See Column Selectors on the documentation website.
Example
// The third quartile of all values in the "age" and "weight" columns
df.percentile(75.0) { age and weight }Return
The given percentile of all the values in the selected columns, as a Double.
Parameters
The percentile to compute, in the range [0.0, 100.0], like 25.0 for the first quartile, 50.0 for the median, or 75.0 for the third quartile. A percentile outside this range causes an IllegalStateException.
The ColumnsSelector used to select the columns to compute the percentile of.
Throws
if there are no values to compute the percentile of.
Returns a single percentile of all the values in the columns of this DataFrame with the given names.
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.
Throws a NoSuchElementException when there is nothing to compute the percentile of, for instance, when the input is empty or contains only null values.
For primitive numbers, the resulting percentile is a Double, interpolated between the values using quantile estimation method R8. Converting Long values to Double may lose precision for very large values. For all other self-comparable values, the resulting percentile is selected from the values using quantile estimation method R3, so it has the same type as those values.
Currently, only the default quantile estimation methods can be used. In the future, it might become possible to choose a different one, see #1121.
For more information about the resulting types: See "percentile Type Conversion" on the documentation website.
See also:
percentileOrNull— returnsnullinstead of throwing when there's nothing to compute the percentile of.percentileFor— the percentile of each selected column separately.median— the median (50th percentile) of all values in the selected columns.The Percentile Operation— an overview of allpercentilemodes.
For more information: See percentile on the documentation website.
Select single or multiple columns using their names as Strings. (String API).
Example
// The third quartile of all values in the "age" and "weight" columns, as a `Double`
df.percentile(75.0, "age", "weight")Return
The given percentile of all the values in the selected columns.
Parameters
The percentile to compute, in the range [0.0, 100.0], like 25.0 for the first quartile, 50.0 for the median, or 75.0 for the third quartile. A percentile outside this range causes an IllegalStateException.
The names of the columns to compute the percentile of. These must be existing columns whose values are mutually comparable, else an IllegalStateException is thrown.
Throws
if there are no values to compute the percentile of.
Aggregates this GroupBy by computing the given percentile of the values of each suitable column separately, per group.
Returns a new DataFrame with one row per group, containing the group key columns and a column with the percentile for each suitable column.
All columns whose values are mutually comparable are taken into account; the other columns are simply left out of the result.
Columns inside column groups are also excluded. To include those in the percentile, flatten the DataFrame first.
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.
For primitive numbers, the resulting percentile is a Double, interpolated between the values using quantile estimation method R8. Converting Long values to Double may lose precision for very large values. For all other self-comparable values, the resulting percentile is selected from the values using quantile estimation method R3, so it has the same type as those values.
Currently, only the default quantile estimation methods can be used. In the future, it might become possible to choose a different one, see #1121.
For more information about the resulting types: See "percentile Type Conversion" on the documentation website.
Result cells for which there is nothing to compute the percentile of (for instance, because the input was empty or contained only null values) simply become null.
See also:
percentileFor— the same, but for an explicit selection of columns.percentile(percentile) { columns }— a single percentile of all values in the selected columns, per group.median— the median (50th percentile) of each column, per group.aggregate— the general way to aggregate groups.The Percentile Operation— an overview of allpercentilemodes.
For more information: See "groupBy statistics" on the documentation website., and See "GroupBy Aggregation Statistics" on the documentation website.
Example
// For each city, the first quartile of each comparable column
df.groupBy { city }.percentile(25.0)Return
A new DataFrame with the group keys and the given percentile of each suitable column per group.
Parameters
The percentile to compute, in the range [0.0, 100.0], like 25.0 for the first quartile, 50.0 for the median, or 75.0 for the third quartile. A percentile outside this range causes an IllegalStateException.
Aggregates this GroupBy by computing a single percentile of all the values in the selected columns, per group.
Returns a new DataFrame with one row per group, containing the group key columns and a single column with the percentile per group. That column is named name, or, if name is null, after the selected column if exactly one column is selected, and "percentile" otherwise.
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.
For primitive numbers, the resulting percentile is a Double, interpolated between the values using quantile estimation method R8. Converting Long values to Double may lose precision for very large values. For all other self-comparable values, the resulting percentile is selected from the values using quantile estimation method R3, so it has the same type as those values.
Currently, only the default quantile estimation methods can be used. In the future, it might become possible to choose a different one, see #1121.
For more information about the resulting types: See "percentile Type Conversion" on the documentation website.
Result cells for which there is nothing to compute the percentile of (for instance, because the input was empty or contained only null values) simply become null.
See Selecting Columns.
See also:
— the percentile of each selected column separately, per group.percentileFor— the percentile of the values a row expression returns for each row of a group.percentileOf— the general way to aggregate groups.aggregateThe Percentile Operation— an overview of allpercentilemodes.
For more information: See "groupBy statistics" on the documentation website., and See "GroupBy Aggregation Statistics" on the documentation website.
Example
// For each city, the first quartile of all values in the "age" and "weight" columns,
// in a column called "q1"
df.groupBy { city }.percentile(25.0, "q1") { age and weight }Return
A new DataFrame with the group keys and a single percentile per group.
Parameters
The percentile to compute, in the range [0.0, 100.0], like 25.0 for the first quartile, 50.0 for the median, or 75.0 for the third quartile. A percentile outside this range causes an IllegalStateException.
The name of the resulting column. If null (the default), the name of the selected column is used if exactly one column is selected, and "percentile" otherwise. This name needs to be unique, else a DuplicateColumnPathInsertException is thrown.
The ColumnsSelector used to select the columns to compute the percentile of.
Aggregates this GroupBy by computing a single percentile of all the values in the selected columns, per group.
Returns a new DataFrame with one row per group, containing the group key columns and a single column with the percentile per group. That column is named name, or, if name is null, after the selected column if exactly one column is selected, and "percentile" otherwise.
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.
For primitive numbers, the resulting percentile is a Double, interpolated between the values using quantile estimation method R8. Converting Long values to Double may lose precision for very large values. For all other self-comparable values, the resulting percentile is selected from the values using quantile estimation method R3, so it has the same type as those values.
Currently, only the default quantile estimation methods can be used. In the future, it might become possible to choose a different one, see #1121.
For more information about the resulting types: See "percentile Type Conversion" on the documentation website.
Result cells for which there is nothing to compute the percentile of (for instance, because the input was empty or contained only null values) simply become null.
See Selecting Columns.
See also:
— the percentile of each selected column separately, per group.percentileFor— the percentile of the values a row expression returns for each row of a group.percentileOf— the general way to aggregate groups.aggregateThe Percentile Operation— an overview of allpercentilemodes.
For more information: See "groupBy statistics" on the documentation website., and See "GroupBy Aggregation Statistics" on the documentation website.
Example
// For each city, the first quartile of all values in the "age" and "weight" columns,
// in a column called "q1"
df.groupBy { city }.percentile(25.0, "age", "weight", name = "q1")Return
A new DataFrame with the group keys and a single percentile per group.
Parameters
The percentile to compute, in the range [0.0, 100.0], like 25.0 for the first quartile, 50.0 for the median, or 75.0 for the third quartile. A percentile outside this range causes an IllegalStateException.
The names of the columns to compute the percentile of. These must be existing columns whose values are mutually comparable, else an IllegalStateException is thrown.
The name of the resulting column. If null (the default), the name of the selected column is used if exactly one column is selected, and "percentile" otherwise. This name needs to be unique, else a DuplicateColumnPathInsertException is thrown.
Aggregates this Pivot by computing the given percentile of the values of each suitable column separately, per group.
Returns a single DataRow with the pivot keys as (nested) columns, containing the percentile of each suitable column of the corresponding group.
All columns whose values are mutually comparable are taken into account; the other columns are simply left out of the result.
Columns inside column groups are also excluded. To include those in the percentile, flatten the DataFrame first.
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.
For primitive numbers, the resulting percentile is a Double, interpolated between the values using quantile estimation method R8. Converting Long values to Double may lose precision for very large values. For all other self-comparable values, the resulting percentile is selected from the values using quantile estimation method R3, so it has the same type as those values.
Currently, only the default quantile estimation methods can be used. In the future, it might become possible to choose a different one, see #1121.
For more information about the resulting types: See "percentile Type Conversion" on the documentation website.
Result cells for which there is nothing to compute the percentile of (for instance, because the input was empty or contained only null values) simply become null.
Check out the .Pivot Grammar
See also:
percentileFor— the same, but for an explicit selection of columns.percentile(percentile) { columns }— a single percentile of all values in the selected columns, per group.Pivot aggregation— all other ways to aggregate aPivot.The Percentile Operation— an overview of allpercentilemodes.
For more information: See "pivot statistics" on the documentation website., and See "Pivot Aggregation statistics" on the documentation website.
Example
// For each city, the first quartile of each comparable column
df.pivot { city }.percentile(25.0)Return
A single DataRow with the given percentile of each suitable column per pivot group.
Parameters
The percentile to compute, in the range [0.0, 100.0], like 25.0 for the first quartile, 50.0 for the median, or 75.0 for the third quartile. A percentile outside this range causes an IllegalStateException.
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.
Aggregates this Pivot by computing a single percentile of all the values in the selected columns, per group.
Returns a single DataRow with the pivot keys as (nested) columns, containing the percentile of all the values in the selected columns of the corresponding group.
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.
For primitive numbers, the resulting percentile is a Double, interpolated between the values using quantile estimation method R8. Converting Long values to Double may lose precision for very large values. For all other self-comparable values, the resulting percentile is selected from the values using quantile estimation method R3, so it has the same type as those values.
Currently, only the default quantile estimation methods can be used. In the future, it might become possible to choose a different one, see #1121.
For more information about the resulting types: See "percentile Type Conversion" on the documentation website.
Result cells for which there is nothing to compute the percentile of (for instance, because the input was empty or contained only null values) simply become null.
See Selecting Columns, or check out the .Pivot Grammar
See also:
percentile(percentile)— the percentile of each suitable column separately, per group.— the percentile of each selected column separately, per group.percentileForPivot aggregation— all other ways to aggregate aPivot.The Percentile Operation— an overview of allpercentilemodes.
For more information: See "pivot statistics" on the documentation website., and See "Pivot Aggregation statistics" on the documentation website.
Example
// For each city, the third quartile of all values in the "age" and "weight" columns
df.pivot { city }.percentile(75.0) { age and weight }Return
A DataRow with, per pivot group, a single given percentile of all the values in the selected columns.
Parameters
The percentile to compute, in the range [0.0, 100.0], like 25.0 for the first quartile, 50.0 for the median, or 75.0 for the third quartile. A percentile outside this range causes an IllegalStateException.
The ColumnsSelector used to select the columns to compute the percentile of.
Aggregates this Pivot by computing a single percentile of all the values in the selected columns, per group.
Returns a single DataRow with the pivot keys as (nested) columns, containing the percentile of all the values in the selected columns of the corresponding group.
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.
For primitive numbers, the resulting percentile is a Double, interpolated between the values using quantile estimation method R8. Converting Long values to Double may lose precision for very large values. For all other self-comparable values, the resulting percentile is selected from the values using quantile estimation method R3, so it has the same type as those values.
Currently, only the default quantile estimation methods can be used. In the future, it might become possible to choose a different one, see #1121.
For more information about the resulting types: See "percentile Type Conversion" on the documentation website.
Result cells for which there is nothing to compute the percentile of (for instance, because the input was empty or contained only null values) simply become null.
See Selecting Columns, or check out the .Pivot Grammar
See also:
percentile(percentile)— the percentile of each suitable column separately, per group.— the percentile of each selected column separately, per group.percentileForPivot aggregation— all other ways to aggregate aPivot.The Percentile Operation— an overview of allpercentilemodes.
For more information: See "pivot statistics" on the documentation website., and See "Pivot Aggregation statistics" on the documentation website.
Example
// For each city, the third quartile of all values in the "age" and "weight" columns
df.pivot { city }.percentile(75.0, "age", "weight")Return
A DataRow with, per pivot group, a single given percentile of all the values in the selected columns.
Parameters
The percentile to compute, in the range [0.0, 100.0], like 25.0 for the first quartile, 50.0 for the median, or 75.0 for the third quartile. A percentile outside this range causes an IllegalStateException.
The names of the columns to compute the percentile of. These must be existing columns whose values are mutually comparable, else an IllegalStateException is thrown.
Aggregates this PivotGroupBy by computing the given percentile of the values of each suitable column separately, per group.
Returns a DataFrame where each cell contains the percentile of each suitable column of the group corresponding to that pivot key (column) and groupBy key (row).
All columns whose values are mutually comparable are taken into account; the other columns are simply left out of the result.
Columns inside column groups are also excluded. To include those in the percentile, flatten the DataFrame first.
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.
For primitive numbers, the resulting percentile is a Double, interpolated between the values using quantile estimation method R8. Converting Long values to Double may lose precision for very large values. For all other self-comparable values, the resulting percentile is selected from the values using quantile estimation method R3, so it has the same type as those values.
Currently, only the default quantile estimation methods can be used. In the future, it might become possible to choose a different one, see #1121.
For more information about the resulting types: See "percentile Type Conversion" on the documentation website.
Result cells for which there exists a group, but there is nothing to compute the percentile of (for instance, because the group was empty or contained only null values) simply become null.
For empty pivot intersections, null or the set default is used.
Check out the .PivotGroupBy Grammar
See also:
percentileFor— the same, but for an explicit selection of columns.percentile(percentile) { columns }— a single percentile of all values in the selected columns, per group.PivotGroupBy aggregation— all other ways to aggregate aPivotGroupBy.The Percentile Operation— an overview of allpercentilemodes.
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 first quartile of each comparable column
df.pivot { city }.groupBy { name.lastName }.percentile(25.0)Return
A DataFrame with the given percentile of each suitable column per pivot and groupBy group.
Parameters
The percentile to compute, in the range [0.0, 100.0], like 25.0 for the first quartile, 50.0 for the median, or 75.0 for the third quartile. A percentile outside this range causes an IllegalStateException.
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.
Aggregates this PivotGroupBy by computing a single percentile of all the values in the selected columns, per group.
Returns a DataFrame where each cell contains the percentile of all the values in the selected columns of the group corresponding to that pivot key (column) and groupBy key (row).
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.
For primitive numbers, the resulting percentile is a Double, interpolated between the values using quantile estimation method R8. Converting Long values to Double may lose precision for very large values. For all other self-comparable values, the resulting percentile is selected from the values using quantile estimation method R3, so it has the same type as those values.
Currently, only the default quantile estimation methods can be used. In the future, it might become possible to choose a different one, see #1121.
For more information about the resulting types: See "percentile Type Conversion" on the documentation website.
Result cells for which there exists a group, but there is nothing to compute the percentile of (for instance, because the group was empty or contained only null values) simply become null.
For empty pivot intersections, null or the set default is used.
See Selecting Columns, or check out the .PivotGroupBy Grammar
See also:
percentile(percentile)— the percentile of each suitable column separately, per group.— the percentile of each selected column separately, per group.percentileForPivotGroupBy aggregation— all other ways to aggregate aPivotGroupBy.The Percentile Operation— an overview of allpercentilemodes.
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 third quartile of all values in the "age" and "weight" columns
df.pivot { city }.groupBy { name.lastName }.percentile(75.0) { age and weight }Return
A DataFrame with, per pivot and groupBy group, a single given percentile of all the values in the selected columns.
Parameters
The percentile to compute, in the range [0.0, 100.0], like 25.0 for the first quartile, 50.0 for the median, or 75.0 for the third quartile. A percentile outside this range causes an IllegalStateException.
The ColumnsSelector used to select the columns to compute the percentile of.
Aggregates this PivotGroupBy by computing a single percentile of all the values in the selected columns, per group.
Returns a DataFrame where each cell contains the percentile of all the values in the selected columns of the group corresponding to that pivot key (column) and groupBy key (row).
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.
For primitive numbers, the resulting percentile is a Double, interpolated between the values using quantile estimation method R8. Converting Long values to Double may lose precision for very large values. For all other self-comparable values, the resulting percentile is selected from the values using quantile estimation method R3, so it has the same type as those values.
Currently, only the default quantile estimation methods can be used. In the future, it might become possible to choose a different one, see #1121.
For more information about the resulting types: See "percentile Type Conversion" on the documentation website.
Result cells for which there exists a group, but there is nothing to compute the percentile of (for instance, because the group was empty or contained only null values) simply become null.
For empty pivot intersections, null or the set default is used.
See Selecting Columns, or check out the .PivotGroupBy Grammar
See also:
percentile(percentile)— the percentile of each suitable column separately, per group.— the percentile of each selected column separately, per group.percentileForPivotGroupBy aggregation— all other ways to aggregate aPivotGroupBy.The Percentile Operation— an overview of allpercentilemodes.
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 third quartile of all values in the "age" and "weight" columns
df.pivot { city }.groupBy { name.lastName }.percentile(75.0, "age", "weight")Return
A DataFrame with, per pivot and groupBy group, a single given percentile of all the values in the selected columns.
Parameters
The percentile to compute, in the range [0.0, 100.0], like 25.0 for the first quartile, 50.0 for the median, or 75.0 for the third quartile. A percentile outside this range causes an IllegalStateException.
The names of the columns to compute the percentile of. These must be existing columns whose values are mutually comparable, else an IllegalStateException is thrown.
Deprecated
It's recommended to migrate to the String or Extension Properties Access API https://kotlin.github.io/dataframe/apilevels.html