{"record":{"id":"9ad0828cfc7f7fea","repo":"pola-rs/polars","slug":"into-datetime-not-implemented-for-dt","errorCode":null,"errorMessage":"into_datetime not implemented for {dt:?}","messagePattern":"into_datetime not implemented for (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/series/mod.rs","lineNumber":997,"sourceCode":"            panic!(\"activate feature dtype-datetime\")\n        }\n\n        #[cfg(feature = \"dtype-datetime\")]\n        match self.dtype() {\n            DataType::Int64 => self\n                .i64()\n                .unwrap()\n                .clone()\n                .into_datetime(timeunit, tz)\n                .into_series(),\n            DataType::Datetime(_, _) => self\n                .datetime()\n                .unwrap()\n                .physical()\n                .clone()\n                .into_datetime(timeunit, tz)\n                .into_series(),\n            dt => panic!(\"into_datetime not implemented for {dt:?}\"),\n        }\n    }\n\n    #[allow(unused_variables)]\n    pub fn into_duration(self, timeunit: TimeUnit) -> Series {\n        #[cfg(not(feature = \"dtype-duration\"))]\n        {\n            panic!(\"activate feature dtype-duration\")\n        }\n        #[cfg(feature = \"dtype-duration\")]\n        match self.dtype() {\n            DataType::Int64 => self\n                .i64()\n                .unwrap()\n                .clone()\n                .into_duration(timeunit)\n                .into_series(),\n            DataType::Duration(_) => self","sourceCodeStart":979,"sourceCodeEnd":1015,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-core/src/series/mod.rs#L979-L1015","documentation":"Series::into_datetime panics when the series' dtype has no datetime conversion. Only Int64 (the datetime physical: epoch in the given time unit) and an existing Datetime dtype are accepted; all other dtypes hit the catch-all panic.","triggerScenarios":"Calling into_datetime(timeunit, tz) on a series whose dtype is neither Int64 nor DataType::Datetime (e.g. Int32, Date, String).","commonSituations":"Reinterpreting Date or Int32 epoch columns as Datetime directly; unit mismatches where epoch seconds were stored as Int32 and must be widened to Int64 first.","solutions":["Ensure the column is Int64 epoch values in the target time unit (cast to Int64 first) before into_datetime","Use series.strict_cast(&DataType::Datetime(timeunit, tz)) which returns a Result instead of panicking","Convert Date to Datetime via the date namespace's cast or dt operations instead"],"exampleFix":"// before\nlet s = series.into_datetime(TimeUnit::Ns, None); // panics for Int32\n// after\nlet s = series.cast(&DataType::Int64)?.into_datetime(TimeUnit::Ns, None);","handlingStrategy":"type-guard","validationCode":"if !matches!(s.dtype(), DataType::Int64 | DataType::Datetime(_, _)) { /* convert first */ }","typeGuard":"fn datetime_convertible(dt: &DataType) -> bool { matches!(dt, DataType::Int64 | DataType::Datetime(_, _)) }","tryCatchPattern":"let s: PolarsResult<Series> = series.strict_cast(&DataType::Datetime(TimeUnit::Ns, None));","preventionTips":["Ensure epoch values are Int64 in the target time unit","Widen Int32 epochs before into_datetime","Use strict_cast for Result-based temporal conversion"],"tags":["polars","rust","panic","datetime","dtype"],"backgroundTag":"unsupported-dtype","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}