ParserOptions

class ParserOptions(val locale: Locale? = null, val dateTime: DateTimeParserOptions<*>? = null, val nullStrings: Set<String>? = null, val skipTypes: Set<KType>? = null, val useFastDoubleParser: Boolean? = null, val parseExperimentalUuid: Boolean? = null, val parseExperimentalInstant: Boolean? = null)

Options for parsing String? columns

These options are used to configure how DataColumns of type String or String? should be parsed. They can be passed to tryParse and parse functions.

You can also use the DataFrame.parser property to access and modify the global parser configuration.

If any of the arguments in ParserOptions are null (or ParserOptions itself is null), the global configuration will be queried.

For more information: See Parser Options on the documentation website.

Parsing date-time strings

By default, DataFrame tries parsing date-time strings using custom formats and patterns defined in the global parser options and using default ISO formats. This is done for both Kotlin- and Java date-time types in order.

However, if a parsing function is provided with ParserOptions and ParserOptions.dateTime is not null, the global GlobalParserOptions.dateTimeLibrary parser option will be overridden.

Concretely, ParserOptions(dateTime = DateTimeParserOptions.Java) is equivalent to having DataFrame.parser.dateTimeLibrary = ParseDateTimeLibrary.JAVA for that particular function call.

In addition, if that org.jetbrains.kotlinx.dataframe.api.DateTimeParserOptions.DateTimeParserOptions has any custom formats or patterns, the custom- and default global formats will be ignored, allowing you to essentially override them.

For example:

// force parsing using Java types only
df.parse(
ParserOptions(dateTime = DateTimeParserOptions.Java),
)
// force parsing using the specified Kotlin LocalDate format only
val dateFormat = LocalDate.Format {
monthNumber(padding = Padding.SPACE); char('/'); day(); char(' '); year()
}
df.parse(
ParserOptions(
dateTime = DateTimeParserOptions.Kotlin
.withFormat(dateFormat),
),
)

For more information: See Parsing Date-time Strings on the documentation website.

See also: DateTimeComponents fallback mechanism

Parameters

locale

locale to use for numbers (and Java date-time types), defaults to the System default locale.

dateTime

Can be used to force parsing to Kotlin-, or Java date-time classes, and override default and custom global date-time formats. By default, it's null, meaning we try Kotlin types first, and if that fails, we try Java types.

nullStrings

a set of strings that should be treated as null values. By default, it's ["null", "NULL", "NA", "N/A"].

skipTypes

a set of types that should be skipped during parsing. Parsing will be attempted for all other types. By default, it's an empty set. To skip all types except a specified one, use convertTo instead.

useFastDoubleParser

whether to use FastDoubleParser, defaults to true. Please report any issues you encounter.

parseExperimentalUuid

whether to allow parsing UUIDs to the Uuid type. This is marked "stable" from Kotlin 2.4.0+, so, by default this is true. NOTE: If you are using an older Kotlin version, interacting with a Uuid in your code might require @OptIn(ExperimentalUuidApi::class). In notebooks, add -opt-in=kotlin.uuid.ExperimentalUuidApi to the compiler arguments.

parseExperimentalInstant

whether to allow parsing to the kotlin.time.Instant type. This is marked "stable" from Kotlin 2.3.0+, so, by default this is true. If false, instants are recognized as the deprecated kotlinx.datetime.Instant type (#1350). NOTE: If you are using an older Kotlin version, interacting with an Instant in your code might require @OptIn(ExperimentalTime::class). In notebooks, add -opt-in=kotlin.time.ExperimentalTime to the compiler arguments.

Constructors

Link copied to clipboard
constructor(locale: Locale? = null, dateTime: DateTimeParserOptions<*>? = null, nullStrings: Set<String>? = null, skipTypes: Set<KType>? = null, useFastDoubleParser: Boolean? = null, parseExperimentalUuid: Boolean? = null, parseExperimentalInstant: Boolean? = null)
constructor(locale: Locale? = null, dateTimeFormatter: DateTimeFormatter? = null, dateTimePattern: String? = null, nullStrings: Set<String>? = null, skipTypes: Set<KType>? = null, useFastDoubleParser: Boolean? = null, parseExperimentalUuid: Boolean? = null, parseExperimentalInstant: Boolean? = null)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun copy(locale: Locale? = this.locale, dateTimeParserOptions: DateTimeParserOptions<*>? = this.dateTime?.copy(), nullStrings: Iterable<String>? = this.nullStrings, skipTypes: Iterable<KType>? = this.skipTypes, useFastDoubleParser: Boolean? = this.useFastDoubleParser, parseExperimentalUuid: Boolean? = this.parseExperimentalUuid, parseExperimentalInstant: Boolean? = this.parseExperimentalInstant): ParserOptions
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String