{"record":{"id":"01e728ba14d75622","repo":"pola-rs/polars","slug":"cannot-create-date-from-other-type-dtype","errorCode":null,"errorMessage":"cannot create date from other type. dtype: {}","messagePattern":"cannot create date from other type\\. dtype: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/datatypes/any_value.rs","lineNumber":953,"sourceCode":"    T: Into<AnyValue<'a>>,\n{\n    #[inline]\n    fn from(a: Option<T>) -> Self {\n        match a {\n            None => AnyValue::Null,\n            Some(v) => v.into(),\n        }\n    }\n}\n\nimpl<'a> AnyValue<'a> {\n    #[cfg(any(feature = \"dtype-date\", feature = \"dtype-datetime\"))]\n    pub(crate) fn as_date(&self) -> AnyValue<'static> {\n        match self {\n            #[cfg(feature = \"dtype-date\")]\n            AnyValue::Int32(v) => AnyValue::Date(*v),\n            AnyValue::Null => AnyValue::Null,\n            av => panic!(\"cannot create date from other type. dtype: {}\", av.dtype()),\n        }\n    }\n\n    #[cfg(feature = \"dtype-datetime\")]\n    pub(crate) fn as_datetime(&self, tu: TimeUnit, tz: Option<&'a TimeZone>) -> AnyValue<'a> {\n        match self {\n            AnyValue::Int64(v) => AnyValue::Datetime(*v, tu, tz),\n            AnyValue::Null => AnyValue::Null,\n            av => panic!(\n                \"cannot create datetime from other type. dtype: {}\",\n                av.dtype()\n            ),\n        }\n    }\n\n    #[cfg(feature = \"dtype-datetime\")]\n    pub(crate) fn as_datetime_owned(\n        &self,","sourceCodeStart":935,"sourceCodeEnd":971,"githubUrl":"https://github.com/pola-rs/polars/blob/68506541d2de983056c9eb244e1ea05fab377dfc/crates/polars-core/src/datatypes/any_value.rs#L935-L971","documentation":"AnyValue::as_date only reinterprets Int32 (the physical date representation) and Null; any other variant panics naming its dtype. Fires when date conversion code calls as_date on a value that is not an Int32 physical date — cast the series to Date first rather than converting per-value.","triggerScenarios":"This panic/expect fires when execution reaches an unguarded state described by: \"cannot create date 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 date 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":["Only construct a Date AnyValue from an Int32 (days since epoch) or another date value.","Cast the source value to Int32 days-since-epoch first."],"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"}