polars.Series.str.to_date#

Series.str.to_date(format: str | None = None, *, strict: bool = True, exact: bool = True, cache: bool = True) Series[source]#

Convert a Utf8 column into a Date column.

Parameters:
format

Format to use for conversion. Refer to the chrono crate documentation for the full specification. Example: "%Y-%m-%d". If set to None (default), the format is inferred from the data.

strict

Raise an error if any conversion fails.

exact

Require an exact format match. If False, allow the format to match anywhere in the target string.

cache

Use a cache of unique, converted dates to apply the conversion.

Examples

>>> s = pl.Series(["2020/01/01", "2020/02/01", "2020/03/01"])
>>> s.str.to_date()
shape: (3,)
Series: '' [date]
[
        2020-01-01
        2020-02-01
        2020-03-01
]