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<Int>()
// Convert all String columns to LocalDate:
df.convert { colsOf<String>() }.to<LocalDate>()
// Convert selected columns to Double with parser options:
df.convert("year", "count").to<Double>(ParserOptions(locale = Locale.GERMAN))
// Converted selected column to Java LocalDate with custom date format:
df.convert { dates }.to<java.time.LocalDate>(ParserOptions(dateTime = JavaDateTimeParserOptions.withPattern("yyyy-MM-dd")))Content copied to clipboard
Return
Parameters
parserOptions
The optional ParserOptions for parsing the String values. Will be ignored if provided for non-String columns.
Type Parameters
D
The target type, provided as a KType, to convert values to.