keysInto

fun <T, C, K, R> Gather<T, C, K, R>.keysInto(keyColumn: String): DataFrame<T>

Reshapes the columns previously selected by gather into a new keyColumn, containing the original column names. The value column is omitted.

Returns a new DataFrame with the reshaped structure. The original gathered columns are removed from the result, while all other columns remain unchanged — except that their values are duplicated for each generated key.

Resulting key values can be adjusted using mapKeys.

For more information, see: See gather on the documentation website.

See also: Grammar.

Example

// Gather names of all columns containing "series" in their name
// into a single "seriesType" column, omitting the value column.
df.gather { cols { it.name().contains("series") } }
.keysInto("seriesType")

Return

A new DataFrame with reshaped columns.

Parameters

keyColumn

The name of the column to store keys (original column names by default).

See also


fun <T, C, K, R> Gather<T, C, K, R>.keysInto(keyColumn: ColumnAccessor<K>): DataFrame<T>
fun <T, C, K, R> Gather<T, C, K, R>.keysInto(keyColumn: KProperty<K>): DataFrame<T>

Deprecated

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