{"record":{"id":"e5a114e783aef1cd","repo":"pola-rs/polars","slug":"only-datetime-duration-inputs-supported-got-dtyp","errorCode":null,"errorMessage":"only Datetime/Duration inputs supported, got {dtype}","messagePattern":"only Datetime/Duration inputs supported, got (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-python/src/interop/numpy/utils.rs","lineNumber":127,"sourceCode":"    use numpy::datetime::{Datetime, Timedelta, units};\n    match dtype {\n        DataType::Datetime(TimeUnit::Milliseconds, _) => {\n            Datetime::<units::Milliseconds>::get_dtype(py)\n        },\n        DataType::Datetime(TimeUnit::Microseconds, _) => {\n            Datetime::<units::Microseconds>::get_dtype(py)\n        },\n        DataType::Datetime(TimeUnit::Nanoseconds, _) => {\n            Datetime::<units::Nanoseconds>::get_dtype(py)\n        },\n        DataType::Duration(TimeUnit::Milliseconds) => {\n            Timedelta::<units::Milliseconds>::get_dtype(py)\n        },\n        DataType::Duration(TimeUnit::Microseconds) => {\n            Timedelta::<units::Microseconds>::get_dtype(py)\n        },\n        DataType::Duration(TimeUnit::Nanoseconds) => Timedelta::<units::Nanoseconds>::get_dtype(py),\n        _ => panic!(\"only Datetime/Duration inputs supported, got {dtype}\"),\n    }\n}\n","sourceCodeStart":109,"sourceCodeEnd":130,"githubUrl":"https://github.com/pola-rs/polars/blob/9b5d73fd00236295624374b075d16b1fe6ec6df9/crates/polars-python/src/interop/numpy/utils.rs#L109-L130","documentation":"Guard in the numpy interop dtype mapping: only Datetime and Duration dtypes (with any time unit) can be converted to numpy datetime/timedelta dtypes; any other polars dtype reaching this helper triggers the error naming the dtype. Convert to a supported type first.","triggerScenarios":"Calling a numpy interop conversion with an array whose dtype is not datetime64/timedelta64.","commonSituations":"See trigger scenarios.","solutions":["Pass a numpy array with a datetime64 or timedelta64 dtype; cast other dtypes first (e.g. arr.astype('datetime64[us]'))."],"exampleFix":"arr = np.array(['2024-01-01'], dtype='datetime64[us]')\npl.from_numpy(arr)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9b5d73fd00236295624374b075d16b1fe6ec6df9","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}