to_datetime#
- skrub.to_datetime(data, format=None)[source]#
Convert DataFrame or column to Datetime dtype.
- Parameters:
- datapandas or polars
{DataFrame, Series}
The dataframe or series to transform.
- format
str
orNone
, optional, default=None Format string to use to parse datetime strings. See the reference documentation for format codes: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes .
- datapandas or polars
- Returns:
- outputpandas or polars {DataFrame,
Series
}. The input transformed to Datetime.
- outputpandas or polars {DataFrame,
See also
ToDatetime
Parse datetimes represented as strings and return Datetime columns.
Examples
>>> import pandas as pd >>> from skrub import to_datetime >>> X = pd.DataFrame(dict(a=[1, 2], b=["01/02/2021", "21/02/2021"])) >>> X a b 0 1 01/02/2021 1 2 21/02/2021 >>> to_datetime(X) a b 0 1 2021-02-01 1 2 2021-02-21