Skip to main content
Version: 1.9.1

Expr.str.to_date

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

Categories: type_casting

Convert the string to a date.

Parameters

parameter
fmt

The date format string (default %Y-%m-%d). See formats <https://docs.rs/chrono/0.4.19/chrono/format/strftime/index.html>_.

parameter
strict

Whether to parse the date strictly.

Examples

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.to_date().alias("to_date"))
>>>
┌────────────┬────────────┐
│ a ┆ to_date │
------
str ┆ date │
╞════════════╪════════════╡
2024-12-132024-12-13
2024-12-152024-12-15
│ null ┆ null │
└────────────┴────────────┘