polars.Series.str.to_date#
- Series.str.to_date( ) Series [source]#
Convert a String 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.
Note
Using
exact=False
introduces a performance penalty - cleaning your data beforehand will almost certainly be more performant.- 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 ]