Skip to main content

to_datetime

Function to_datetime 

Source
pub fn to_datetime(series: &Series) -> Result<Series, FrameError>
Expand description

Convert a Series of strings or integers to normalized ISO 8601 datetime strings.

Matches pd.to_datetime(series). Since FrankenPandas stores datetimes as Utf8 (ISO 8601 strings), this function normalizes various input formats:

  • ISO 8601: “2024-01-15”, “2024-01-15T10:30:00”, “2024-01-15 10:30:00”
  • Date-only with slashes: “2024/01/15”, “01/15/2024”
  • Epoch seconds (Int64): Unix timestamp integers
  • Epoch milliseconds (Int64 > 1e11): Auto-detected as ms

Optional format parameter provides explicit format string (subset of strftime: %Y, %m, %d, %H, %M, %S).

Missing/unparseable values become Null.