polars.Series.str.to_time#

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

Convert a String column into a Time column.

Parameters:
format

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

strict

Raise an error if any conversion fails.

cache

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

Examples

>>> s = pl.Series(["01:00", "02:00", "03:00"])
>>> s.str.to_time("%H:%M")
shape: (3,)
Series: '' [time]
[
        01:00:00
        02:00:00
        03:00:00
]