{"record":{"id":"fb250b56c1a2b17d","repo":"pola-rs/polars","slug":"cannot-create-time-from-other-type-dtype","errorCode":null,"errorMessage":"cannot create time from other type. dtype: {}","messagePattern":"cannot create time from other type\\. dtype: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/datatypes/any_value.rs","lineNumber":1002,"sourceCode":"\n    #[cfg(feature = \"dtype-duration\")]\n    pub(crate) fn as_duration(&self, tu: TimeUnit) -> AnyValue<'static> {\n        match self {\n            AnyValue::Int64(v) => AnyValue::Duration(*v, tu),\n            AnyValue::Null => AnyValue::Null,\n            av => panic!(\n                \"cannot create duration from other type. dtype: {}\",\n                av.dtype()\n            ),\n        }\n    }\n\n    #[cfg(feature = \"dtype-time\")]\n    pub(crate) fn as_time(&self) -> AnyValue<'static> {\n        match self {\n            AnyValue::Int64(v) => AnyValue::Time(*v),\n            AnyValue::Null => AnyValue::Null,\n            av => panic!(\"cannot create time from other type. dtype: {}\", av.dtype()),\n        }\n    }\n\n    pub(crate) fn to_i128(&self) -> Option<i128> {\n        match self {\n            AnyValue::UInt8(v) => Some((*v).into()),\n            AnyValue::UInt16(v) => Some((*v).into()),\n            AnyValue::UInt32(v) => Some((*v).into()),\n            AnyValue::UInt64(v) => Some((*v).into()),\n            AnyValue::Int8(v) => Some((*v).into()),\n            AnyValue::Int16(v) => Some((*v).into()),\n            AnyValue::Int32(v) => Some((*v).into()),\n            AnyValue::Int64(v) => Some((*v).into()),\n            AnyValue::Int128(v) => Some(*v),\n            _ => None,\n        }\n    }\n","sourceCodeStart":984,"sourceCodeEnd":1020,"githubUrl":"https://github.com/pola-rs/polars/blob/68506541d2de983056c9eb244e1ea05fab377dfc/crates/polars-core/src/datatypes/any_value.rs#L984-L1020","documentation":"AnyValue::as_time reinterprets only Int64 (physical time-of-day) and Null; any other variant panics with this message naming the dtype. Fires when time conversion is requested from a non-Int64 AnyValue.","triggerScenarios":"This panic/expect fires when execution reaches an unguarded state described by: \"cannot create time from other type. dtype: {}\". 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.","commonSituations":"Encountered when input data or configuration does not meet the preconditions of the throwing code path (\"cannot create time from other type. dtype: {}\"). 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.","solutions":["Construct Time AnyValues only from Int64 nanoseconds-since-midnight.","Convert the source value to the time representation before creating the AnyValue."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"68506541d2de983056c9eb244e1ea05fab377dfc","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}