to

fun to(vararg newNames: String): DataFrame<T>

Renames the columns selected with rename to the specified newNames, preserving their values and positions within the DataFrame.

The mapping is positional: newNames are applied in the order the columns were selected — the first selected column is renamed to the first name, the second to the second, and so on.

For more information: See rename on the documentation website.

Check out Grammar.

Examples:

// Rename "col1" to "width" and "col2" to "length"
df.rename("col1", "col2").to("width", "length")

// Rename "col1" to "width" and "col2" to "length"
df.rename { col1 and col2 }.to("width", "length")

Return

A new DataFrame with the columns renamed.

Parameters

newNames

The new names for the selected columns, applied in order of selecting.


fun to(transform: (ColumnWithPath<C>) -> String): DataFrame<T>

Renames the columns selected with rename by applying the transform expression to each of them. This expression receives the column together with its full path (as ColumnWithPath) and must return the new name for that column. The operation preserves the original columns’ values and their positions within the DataFrame.

For more information: See rename on the documentation website.

Check out Grammar for more details.

Examples:

// Rename all columns using their full path, delimited by "->"
df.rename { colsAtAnyDepth() }.to { it.path.joinToString("->") }

// Rename all `String` columns with uppercase
df.rename { colsOf<String>() }.to { it.name.uppercase() }

Return

A new DataFrame with the columns renamed.

Parameters

transform

A function that takes a ColumnWithPath for each selected column and returns the new column name.