Pivot

interface Pivot<T> : Aggregatable<T>

A dataframe-like structure that contains all unique combinations of key values as columns (or column groups for multiple keys) with a single row with the corresponding groups for each key combination (each represented as a DataFrame).

Similar to GroupBy but contains horizontal groups.

A Pivot can be:

Check out Pivot Grammar.

For more information: See pivot on the documentation website.

Inheritors

Functions

Link copied to clipboard
fun <T, R> Pivot<T>.aggregate(separate: Boolean = false, body: Selector<AggregateDsl<T>, R>): DataRow<T>

Aggregates this Pivot using the provided statistics inside the AggregateDsl.

Link copied to clipboard
fun <T> Pivot<T>.count(): DataRow<T>

Aggregates this Pivot by counting the number of rows in each group.

inline fun <T> Pivot<T>.count(crossinline predicate: RowFilter<T>): DataRow<T>

Aggregates this Pivot by counting the number of rows in each group that satisfy the given predicate.

Link copied to clipboard
internal inline fun <T> Pivot<T>.delegate(crossinline body: PivotGroupBy<T>.() -> DataFrame<T>): DataRow<T>
Link copied to clipboard

Reduces this Pivot by taking the first row from each group, and returns a ReducedPivot that contains the first row from the corresponding group in each column.

fun <T> Pivot<T>.first(predicate: RowFilter<T>): ReducedPivot<T>

Reduces this Pivot by taking from each group the first row satisfying the given predicate, and returns a ReducedPivot that contains the first row, matching the predicate, from the corresponding group in each column.

Link copied to clipboard
fun <T> Pivot<T>.frames(): DataRow<T>
Link copied to clipboard
fun <T> Pivot<T>.groupBy(vararg columns: String): PivotGroupBy<T>
fun <T> Pivot<T>.groupBy(moveToTop: Boolean = true, columns: ColumnsSelector<T, *>): PivotGroupBy<T>

Groups the rows of this Pivot groups based on the values in one or more specified key columns. Returns a PivotGroupBy.

fun <T> Pivot<T>.groupBy(vararg columns: KProperty<*>): PivotGroupBy<T>
fun <T> Pivot<T>.groupBy(vararg columns: ColumnReference<*>): PivotGroupBy<T>
Link copied to clipboard

Groups the rows of this Pivot into a PivotGroupBy based on the values of all columns except the pivot key columns. For example, if a DataFrame has columns "a", "b", "c", "d" and is pivoted by "a" and "c", then this Pivot will be grouped by the remaining columns "b" and "d".

Link copied to clipboard
Link copied to clipboard

Emulates selecting all columns whose values are mutually comparable to each other. These are columns of type R where R : Comparable<R>.

Link copied to clipboard
fun <T> Pivot<T>.last(): ReducedPivot<T>

Reduces this Pivot by taking the last row from each group, and returns a ReducedPivot that contains the last row from the corresponding group in each column.

fun <T> Pivot<T>.last(predicate: RowFilter<T>): ReducedPivot<T>

Reduces this Pivot by taking from each group the last row satisfying the given predicate, and returns a ReducedPivot that contains the last row, matching the predicate, from the corresponding group in each column.

Link copied to clipboard
fun <T> Pivot<T>.max(separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>

Aggregates this Pivot by computing the maximum of the values of each suitable column separately, per group.

fun <T, R : Comparable<R & Any>?> Pivot<T>.max(skipNaN: Boolean = skipNaNDefault, columns: ColumnsSelector<T, R>): DataRow<T>
fun <T> Pivot<T>.max(vararg columns: String, skipNaN: Boolean = skipNaNDefault): DataRow<T>

Aggregates this Pivot by computing a single maximum of all the values in the selected columns, per group.

fun <T, R : Comparable<R & Any>?> Pivot<T>.max(vararg columns: KProperty<R>, skipNaN: Boolean = skipNaNDefault): DataRow<T>
fun <T, R : Comparable<R & Any>?> Pivot<T>.max(vararg columns: ColumnReference<R>, skipNaN: Boolean = skipNaNDefault): DataRow<T>
Link copied to clipboard
inline fun <T, reified R : Comparable<R & Any>?> Pivot<T>.maxBy(skipNaN: Boolean = skipNaNDefault, crossinline rowExpression: RowExpression<T, R>): ReducedPivot<T>

Reduces this Pivot by taking from each group the first row for which the given rowExpression returns the maximum value.

fun <T> Pivot<T>.maxBy(column: String, skipNaN: Boolean = skipNaNDefault): ReducedPivot<T>

Reduces this Pivot by taking from each group the first row that has the largest value in the given column.

inline fun <T, reified C : Comparable<C & Any>?> Pivot<T>.maxBy(column: KProperty<C>, skipNaN: Boolean = skipNaNDefault): ReducedPivot<T>
inline fun <T, reified C : Comparable<C & Any>?> Pivot<T>.maxBy(column: ColumnReference<C>, skipNaN: Boolean = skipNaNDefault): ReducedPivot<T>
Link copied to clipboard
fun <T, R : Comparable<*>?> Pivot<T>.maxFor(separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, columns: ColumnsForAggregateSelector<T, R>): DataRow<T>
fun <T> Pivot<T>.maxFor(vararg columns: String, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>

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

fun <T, R : Comparable<*>?> Pivot<T>.maxFor(vararg columns: KProperty<R>, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>
fun <T, R : Comparable<*>?> Pivot<T>.maxFor(vararg columns: ColumnReference<R>, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>
Link copied to clipboard
inline fun <T, reified R : Comparable<R & Any>?> Pivot<T>.maxOf(skipNaN: Boolean = skipNaNDefault, crossinline rowExpression: RowExpression<T, R>): DataRow<T>

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

Link copied to clipboard
fun <T> Pivot<T>.mean(skipNaN: Boolean = skipNaNDefault, separate: Boolean = false): DataRow<T>

Aggregates this Pivot by computing the mean of the values of each suitable column separately, per group.

fun <T, R : Number?> Pivot<T>.mean(skipNaN: Boolean = skipNaNDefault, columns: ColumnsSelector<T, R>): DataRow<T>

Aggregates this Pivot by computing a single mean of means of the selected columns, per group.

Link copied to clipboard
fun <T, C : Number?> Pivot<T>.meanFor(skipNaN: Boolean = skipNaNDefault, separate: Boolean = false, columns: ColumnsForAggregateSelector<T, C>): DataRow<T>
fun <T> Pivot<T>.meanFor(vararg columns: String, skipNaN: Boolean = skipNaNDefault, separate: Boolean = false): DataRow<T>

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

fun <T, C : Number?> Pivot<T>.meanFor(vararg columns: KProperty<C>, skipNaN: Boolean = skipNaNDefault, separate: Boolean = false): DataRow<T>
fun <T, C : Number?> Pivot<T>.meanFor(vararg columns: ColumnReference<C>, skipNaN: Boolean = skipNaNDefault, separate: Boolean = false): DataRow<T>
Link copied to clipboard
inline fun <T, reified R : Number?> Pivot<T>.meanOf(skipNaN: Boolean = skipNaNDefault, crossinline expression: RowExpression<T, R>): DataRow<T>

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

Link copied to clipboard
fun <T> Pivot<T>.median(separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>

Aggregates this Pivot by computing the median of the values of each suitable column separately, per group.

fun <T, C : Comparable<C & Any>?> Pivot<T>.median(skipNaN: Boolean = skipNaNDefault, columns: ColumnsSelector<T, C>): DataRow<T>
fun <T> Pivot<T>.median(vararg columns: String, skipNaN: Boolean = skipNaNDefault): DataRow<T>

Aggregates this Pivot by computing a single median of all the values in the selected columns, per group.

fun <T, C : Comparable<C & Any>?> Pivot<T>.median(vararg columns: KProperty<C>, skipNaN: Boolean = skipNaNDefault): DataRow<T>
fun <T, C : Comparable<C & Any>?> Pivot<T>.median(vararg columns: ColumnReference<C>, skipNaN: Boolean = skipNaNDefault): DataRow<T>
Link copied to clipboard
inline fun <T, reified R : Comparable<R & Any>?> Pivot<T>.medianBy(skipNaN: Boolean = skipNaNDefault, crossinline rowExpression: RowExpression<T, R>): ReducedPivot<T>

Reduces this Pivot by taking from each group the row at the median of the values that the given rowExpression returns for each row of that group.

fun <T> Pivot<T>.medianBy(column: String, skipNaN: Boolean = skipNaNDefault): ReducedPivot<T>

Reduces this Pivot by taking from each group the row at the median of the values in the given column.

inline fun <T, reified C : Comparable<C & Any>?> Pivot<T>.medianBy(column: KProperty<C>, skipNaN: Boolean = skipNaNDefault): ReducedPivot<T>
inline fun <T, reified C : Comparable<C & Any>?> Pivot<T>.medianBy(column: ColumnReference<C>, skipNaN: Boolean = skipNaNDefault): ReducedPivot<T>
Link copied to clipboard
fun <T, C : Comparable<*>?> Pivot<T>.medianFor(separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, columns: ColumnsForAggregateSelector<T, C>): DataRow<T>
fun <T> Pivot<T>.medianFor(vararg columns: String, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>

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

fun <T, C : Comparable<*>?> Pivot<T>.medianFor(vararg columns: KProperty<C>, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>
fun <T, C : Comparable<*>?> Pivot<T>.medianFor(vararg columns: ColumnReference<C>, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>
Link copied to clipboard
inline fun <T, reified R : Comparable<R & Any>?> Pivot<T>.medianOf(skipNaN: Boolean = skipNaNDefault, crossinline expression: RowExpression<T, R>): DataRow<T>

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

Link copied to clipboard
fun <T> Pivot<T>.min(separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>

Aggregates this Pivot by computing the minimum of the values of each suitable column separately, per group.

fun <T, R : Comparable<R & Any>?> Pivot<T>.min(skipNaN: Boolean = skipNaNDefault, columns: ColumnsSelector<T, R>): DataRow<T>
fun <T> Pivot<T>.min(vararg columns: String, skipNaN: Boolean = skipNaNDefault): DataRow<T>

Aggregates this Pivot by computing a single minimum of all the values in the selected columns, per group.

fun <T, R : Comparable<R & Any>?> Pivot<T>.min(vararg columns: KProperty<R>, skipNaN: Boolean = skipNaNDefault): DataRow<T>
fun <T, R : Comparable<R & Any>?> Pivot<T>.min(vararg columns: ColumnReference<R>, skipNaN: Boolean = skipNaNDefault): DataRow<T>
Link copied to clipboard
inline fun <T, reified R : Comparable<R & Any>?> Pivot<T>.minBy(skipNaN: Boolean = skipNaNDefault, crossinline rowExpression: RowExpression<T, R>): ReducedPivot<T>

Reduces this Pivot by taking from each group the first row for which the given rowExpression returns the minimum value.

fun <T> Pivot<T>.minBy(column: String, skipNaN: Boolean = skipNaNDefault): ReducedPivot<T>

Reduces this Pivot by taking from each group the first row that has the smallest value in the given column.

inline fun <T, reified C : Comparable<C & Any>?> Pivot<T>.minBy(column: KProperty<C>, skipNaN: Boolean = skipNaNDefault): ReducedPivot<T>
inline fun <T, reified C : Comparable<C & Any>?> Pivot<T>.minBy(column: ColumnReference<C>, skipNaN: Boolean = skipNaNDefault): ReducedPivot<T>
Link copied to clipboard
fun <T, R : Comparable<*>?> Pivot<T>.minFor(separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, columns: ColumnsForAggregateSelector<T, R>): DataRow<T>
fun <T> Pivot<T>.minFor(vararg columns: String, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>

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

fun <T, R : Comparable<*>?> Pivot<T>.minFor(vararg columns: KProperty<R>, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>
fun <T, R : Comparable<*>?> Pivot<T>.minFor(vararg columns: ColumnReference<R>, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>
Link copied to clipboard
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.

Link copied to clipboard
Link copied to clipboard
fun <T> Pivot<T>.percentile(percentile: Double, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>

Aggregates this Pivot by computing the given percentile of the values of each suitable column separately, per group.

fun <T, C : Comparable<C & Any>?> Pivot<T>.percentile(percentile: Double, skipNaN: Boolean = skipNaNDefault, columns: ColumnsSelector<T, C>): DataRow<T>
fun <T> Pivot<T>.percentile(percentile: Double, vararg columns: String, skipNaN: Boolean = skipNaNDefault): DataRow<T>

Aggregates this Pivot by computing a single percentile of all the values in the selected columns, per group.

fun <T, C : Comparable<C & Any>?> Pivot<T>.percentile(percentile: Double, vararg columns: KProperty<C>, skipNaN: Boolean = skipNaNDefault): DataRow<T>
fun <T, C : Comparable<C & Any>?> Pivot<T>.percentile(percentile: Double, vararg columns: ColumnReference<C>, skipNaN: Boolean = skipNaNDefault): DataRow<T>
Link copied to clipboard
inline fun <T, reified R : Comparable<R & Any>?> Pivot<T>.percentileBy(percentile: Double, skipNaN: Boolean = skipNaNDefault, crossinline rowExpression: RowExpression<T, R>): ReducedPivot<T>

Reduces this Pivot by taking from each group the row at the given percentile of the values that the given rowExpression returns for each row of that group.

fun <T> Pivot<T>.percentileBy(percentile: Double, column: String, skipNaN: Boolean = skipNaNDefault): ReducedPivot<T>

Reduces this Pivot by taking from each group the row at the given percentile of the values in the given column.

inline fun <T, reified C : Comparable<C & Any>?> Pivot<T>.percentileBy(percentile: Double, column: KProperty<C>, skipNaN: Boolean = skipNaNDefault): ReducedPivot<T>
inline fun <T, reified C : Comparable<C & Any>?> Pivot<T>.percentileBy(percentile: Double, column: ColumnReference<C>, skipNaN: Boolean = skipNaNDefault): ReducedPivot<T>
Link copied to clipboard
fun <T, C : Comparable<*>?> Pivot<T>.percentileFor(percentile: Double, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, columns: ColumnsForAggregateSelector<T, C>): DataRow<T>
fun <T> Pivot<T>.percentileFor(percentile: Double, vararg columns: String, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>

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

fun <T, C : Comparable<*>?> Pivot<T>.percentileFor(percentile: Double, vararg columns: KProperty<C>, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>
fun <T, C : Comparable<*>?> Pivot<T>.percentileFor(percentile: Double, vararg columns: ColumnReference<C>, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>
Link copied to clipboard
inline fun <T, reified R : Comparable<R & Any>?> Pivot<T>.percentileOf(percentile: Double, skipNaN: Boolean = skipNaNDefault, crossinline expression: RowExpression<T, R>): DataRow<T>

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

Link copied to clipboard
internal fun <T> Pivot<T>.reduce(reducer: Selector<DataFrame<T>, DataRow<T>?>): ReducedPivot<T>
Link copied to clipboard
internal inline fun <T> Aggregatable<T>.remainingColumns(crossinline predicate: (AnyCol) -> Boolean): ColumnsSelector<T, Any?>
Link copied to clipboard
Link copied to clipboard
fun <T> Pivot<T>.std(separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataRow<T>

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

fun <T, C : Number?> Pivot<T>.std(skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault, columns: ColumnsSelector<T, C>): DataRow<T>
fun <T> Pivot<T>.std(vararg columns: String, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataRow<T>

Aggregates this Pivot by computing a single standard deviation of all the values in the selected columns, per group.

fun <T, C : Number?> Pivot<T>.std(vararg columns: KProperty<C>, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataRow<T>
fun <T, C : Number?> Pivot<T>.std(vararg columns: ColumnReference<C>, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataRow<T>
Link copied to clipboard
fun <T, R : Number?> Pivot<T>.stdFor(separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault, columns: ColumnsForAggregateSelector<T, R>): DataRow<T>
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.

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?> Pivot<T>.stdFor(vararg columns: ColumnReference<C>, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, ddof: Int = ddofDefault): DataRow<T>
Link copied to clipboard
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.

Link copied to clipboard
fun <T> Pivot<T>.sum(separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>

Aggregates this Pivot by computing the sum of the values of each suitable column separately, per group.

fun <T, C : Number?> Pivot<T>.sum(skipNaN: Boolean = skipNaNDefault, columns: ColumnsSelector<T, C>): DataRow<T>
fun <T> Pivot<T>.sum(vararg columns: String, skipNaN: Boolean = skipNaNDefault): DataRow<T>

Aggregates this Pivot by computing a single sum of all the values in the selected columns, per group.

fun <T, C : Number?> Pivot<T>.sum(vararg columns: KProperty<C>, skipNaN: Boolean = skipNaNDefault): DataRow<T>
fun <T, C : Number?> Pivot<T>.sum(vararg columns: ColumnReference<C>, skipNaN: Boolean = skipNaNDefault): DataRow<T>
Link copied to clipboard
fun <T, R : Number?> Pivot<T>.sumFor(separate: Boolean = false, skipNaN: Boolean = skipNaNDefault, columns: ColumnsForAggregateSelector<T, R>): DataRow<T>
fun <T> Pivot<T>.sumFor(vararg columns: String, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>

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

fun <T, C : Number?> Pivot<T>.sumFor(vararg columns: KProperty<C>, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>
fun <T, C : Number?> Pivot<T>.sumFor(vararg columns: ColumnReference<C>, separate: Boolean = false, skipNaN: Boolean = skipNaNDefault): DataRow<T>
Link copied to clipboard
inline fun <T, reified R : Number?> Pivot<T>.sumOf(skipNaN: Boolean = skipNaNDefault, crossinline expression: RowExpression<T, R>): DataRow<T>

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

Link copied to clipboard
fun <T> Pivot<T>.values(dropNA: Boolean = false, distinct: Boolean = false, separate: Boolean = false): DataRow<T>
fun <T> Pivot<T>.values(dropNA: Boolean = false, distinct: Boolean = false, separate: Boolean = false, columns: ColumnsForAggregateSelector<T, *>): DataRow<T>
fun <T> Pivot<T>.values(vararg columns: String, dropNA: Boolean = false, distinct: Boolean = false, separate: Boolean = false): DataRow<T>
fun <T> Pivot<T>.values(vararg columns: KProperty<*>, dropNA: Boolean = false, distinct: Boolean = false, separate: Boolean = false): DataRow<T>
fun <T> Pivot<T>.values(vararg columns: ColumnReference<*>, dropNA: Boolean = false, distinct: Boolean = false, separate: Boolean = false): DataRow<T>
Link copied to clipboard
inline fun <T, reified V> Pivot<T>.with(noinline expression: RowExpression<T, V>): DataRow<T>

Aggregates this Pivot by evaluating the given row expression on every row of each pivot group.