pola-rs/polars · error
into_datetime not implemented for {dt:?}
Error message
into_datetime not implemented for {dt:?} What it means
Series::into_datetime (with dtype-datetime enabled) accepts only Int64 physical values and Datetime series; any other dtype reaches the terminal panic naming it. E.g. calling into_datetime on an Int32 or Date series triggers it — cast to Int64 (microseconds) first.
Source
Thrown at crates/polars-core/src/series/mod.rs:984
panic!("activate feature dtype-datetime")
}
#[cfg(feature = "dtype-datetime")]
match self.dtype() {
DataType::Int64 => self
.i64()
.unwrap()
.clone()
.into_datetime(timeunit, tz)
.into_series(),
DataType::Datetime(_, _) => self
.datetime()
.unwrap()
.physical()
.clone()
.into_datetime(timeunit, tz)
.into_series(),
dt => panic!("into_datetime not implemented for {dt:?}"),
}
}
#[allow(unused_variables)]
pub fn into_duration(self, timeunit: TimeUnit) -> Series {
#[cfg(not(feature = "dtype-duration"))]
{
panic!("activate feature dtype-duration")
}
#[cfg(feature = "dtype-duration")]
match self.dtype() {
DataType::Int64 => self
.i64()
.unwrap()
.clone()
.into_duration(timeunit)
.into_series(),
DataType::Duration(_) => selfView on GitHub (pinned to 68506541d2)
Solutions
- Convert to Datetime only from supported dtypes (Date, Int64 timestamps, strings via strptime).
- Cast the source series to Int64 with the correct time unit first.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: This panic/expect fires when execution reaches an unguarded state described by: "into_datetime not implemented for {dt:?}". Typical triggers: unsupported dtype or feature-gated code path reached at runtime, invalid user input or environment variable value, calling API methods in the wrong order or on mismatched types, or data (lengths, offsets, ranges) violating the function's preconditions.
Common situations: Encountered when input data or configuration does not meet the preconditions of the throwing code path ("into_datetime not implemented for {dt:?}"). Common cases: missing Cargo feature flags, mismatched dtypes/lengths between arrays or series, out-of-range temporal values, malformed environment variables, or operations on unsupported/complex nested types.
AI-assisted analysis of pola-rs/polars@68506541d2 (2026-08-19).
Data as JSON: /api/errors/9ad0828cfc7f7fea.
Report an issue: GitHub.