to
Converts the values in the columns previously selected with convert to the specified type, preserving their original names and positions within the DataFrame.
The target type is provided as reified argument. For the full list of supported types, see SupportedTypes.
Converting from String(?) columns is considered "parsing". You can also provide parserOptions to customize the Locale, date-time options, etc. See ParserOptions. This argument is ignored for non-String columns.
For more information: See convert on the documentation website.
Examples:
// Convert selected columns to Int:
df.convert("year", "count").to(typeOf<Int>())
// Convert all String columns to LocalDate:
df.convert { colsOf<String>() }.to(typeOf<LocalDate>())
// Convert selected columns to Double with parser options:
df.convert("year", "count").to(typeOf<Double>(), ParserOptions(locale = Locale.GERMAN))
// Converted selected column to Java LocalDate with custom date format:
df.convert { dates }.to(typeOf<java.time.LocalDate>(), ParserOptions(dateTime = JavaDateTimeParserOptions.withPattern("yyyy-MM-dd")))Return
Parameters
The target type, provided as a KType, to convert values to.
The optional ParserOptions for parsing the String values. Will be ignored if provided for non-String columns.
Moves columns, previously selected with move to a new position specified by columnIndex within the DataFrame.
Returns a new DataFrame with an updated column structure.
For more information: See move on the documentation website.
Examples:
df.move { age and weight }.to(0)
df.move("age", "weight").to(2)Parameters
The index specifying the position in the DataFrame columns
where the selected columns will be moved.
Moves columns, previously selected with move to a new position specified by columnIndex. If insideGroup is true, selected columns will be moved remaining within their ColumnGroup, else they will be moved to the top level.
Returns a new DataFrame with an updated column structure.
For more information: See move on the documentation website.
Examples:
df.move { age and weight }.to(0, true)
df.move("age", "weight").to(2, false)Parameters
The index specifying the position in the ColumnGroup columns where the selected columns will be moved.
If true, selected columns will be moved remaining inside their group, else they will be moved to the top level.
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
The new names for the selected columns, applied in order of selecting.
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
A function that takes a ColumnWithPath for each selected column and returns the new column name.
Deprecated (with error)
This to overload will be removed in favor of `asColumn`. Will be ERROR in 1.0.
Replace with
this.asColumn(columnConverter)