pola-rs/polars · error
into_decimal({precision:?}, {scale}) not implemented for {dt
Error message
into_decimal({precision:?}, {scale}) not implemented for {dt:?} What it means
Series::into_decimal only converts Int128 and already-decimal series with compatible precision/scale; any other dtype reaches the terminal panic arm naming the actual dtype. Fires when calling into_decimal on e.g. a Float64 or String series instead of first casting to an integer type.
Source
Thrown at crates/polars-core/src/series/mod.rs:924
pub fn strict_cast(&self, dtype: &DataType) -> PolarsResult<Series> {
self.cast_with_options(dtype, CastOptions::Strict)
}
#[cfg(feature = "dtype-decimal")]
pub fn into_decimal(self, precision: usize, scale: usize) -> PolarsResult<Series> {
match self.dtype() {
DataType::Int128 => Ok(self
.i128()
.unwrap()
.clone()
.into_decimal(precision, scale)?
.into_series()),
DataType::Decimal(cur_prec, cur_scale)
if scale == *cur_scale && precision >= *cur_prec =>
{
Ok(self)
},
dt => panic!("into_decimal({precision:?}, {scale}) not implemented for {dt:?}"),
}
}
#[cfg(feature = "dtype-time")]
pub fn into_time(self) -> Series {
match self.dtype() {
DataType::Int64 => self.i64().unwrap().clone().into_time().into_series(),
DataType::Time => self
.time()
.unwrap()
.physical()
.clone()
.into_time()
.into_series(),
dt => panic!("date not implemented for {dt:?}"),
}
}
View on GitHub (pinned to 68506541d2)
Solutions
- Convert the series to Decimal only from supported numeric dtypes; cast to Int128/Float first if available.
- Scale the values to integers and attach the decimal metadata manually.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: This panic/expect fires when execution reaches an unguarded state described by: "into_decimal({precision:?}, {scale}) 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_decimal({precision:?}, {scale}) 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/1c7882c913d6a428.
Report an issue: GitHub.