Dataframe 0.14 Help

parse

Returns a DataFrame in which the given String columns are parsed into other types.

This is a special case of the convert operation.

df.parse()

To parse only particular columns use a column selector:

df.parse { age and weight }

parse tries to parse every String column into one of supported types in the following order:

  • Int

  • Long

  • Instant (kotlinx.datetime and java.time)

  • LocalDateTime (kotlinx.datetime and java.time)

  • LocalDate (kotlinx.datetime and java.time)

  • Duration (kotlin.time and java.time)

  • LocalTime (java.time)

  • URL (java.net)

  • Double (with optional locale settings)

  • Boolean

  • BigDecimal

  • JSON (arrays and objects)

Available parser options:

  • locale: Locale is used to parse doubles

  • dateTimePattern: String is used to parse date and time

  • dateTimeFormatter: DateTimeFormatter is used to parse date and time

  • nullStrings: List<String> is used to treat particular strings as null value. Default null strings are "null" and "NULL"

df.parse(options = ParserOptions(locale = Locale.CHINA, dateTimeFormatter = DateTimeFormatter.ISO_WEEK_DATE))

You can also set global parser options that will be used by default in read, convert, and parse operations:

DataFrame.parser.locale = Locale.FRANCE DataFrame.parser.addDateTimePattern("dd.MM.uuuu HH:mm:ss")
Last modified: 27 September 2024