Expr.str.to_date
methodView source ↗
def to_date(fmt: str | None = None, strict: bool = True) -> Expr
Categories: type_casting
Convert the string to a date.
Parameters
parameter
fmtThe date format string (default %Y-%m-%d). See formats <https://docs.rs/chrono/0.4.19/chrono/format/strftime/index.html>_.
parameter
strictWhether 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-13 ┆ 2024-12-13 │
│ 2024-12-15 ┆ 2024-12-15 │
│ null ┆ null │
└────────────┴────────────┘