Skip to content

Convert a String column into a Time column

Source code

Description

Convert a String column into a Time column

Usage

<Expr>$str$to_time(format = NULL, ..., strict = TRUE, cache = TRUE)

Arguments

format Format to use for conversion. Refer to the chrono crate documentation for the full specification. Example: ā€œ%Y-%m-%d %H:%M:%Sā€. If NULL (default), the format is inferred from the data. Notice that time zone %Z is not supported and will just ignore timezones. Numeric time zones like %z or %:z are supported.
ā€¦ Not used.
strict If TRUE (default), raise an error if a single string cannot be parsed. If FALSE, produce a polars null.
cache Use a cache of unique, converted dates to apply the datetime conversion.

Value

Expr of Time type

See Also

  • \$str$strptime()

Examples

library("polars")

s = as_polars_series(c("01:00", "02:00", "03:00"))

s$str$to_time("%H:%M")
#> polars Series: shape: (3,)
#> Series: '' [time]
#> [
#>  01:00:00
#>  02:00:00
#>  03:00:00
#> ]