Skip to main content
Version: 1.9.1

Expr.str.to_time

def to_time(fmt: str | None = None, strict: bool = True, cache: bool = True) -> Expr

Categories: type_casting

Convert the string to a time.

Parameters

parameter
fmt

The time format string (default %H:%M:%S). See formats <https://docs.rs/chrono/0.4.19/chrono/format/strftime/index.html>_.

parameter
strict

Whether to parse the date strictly.

parameter
cache

Whether to cache the date.

Examples

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.to_time().alias("to_time"))
>>>
┌─────────────────────┬─────────────────────┐
│ a ┆ to_datetime │
------
str ┆ datetime[μs]
╞═════════════════════╪═════════════════════╡
2024-12-13 08:45:342024-12-13 08:45:34
2024-12-15 18:33:002024-12-15 18:33:00
│ null ┆ null │
└─────────────────────┴─────────────────────┘