{"record":{"id":"acd69bd528d08c36","repo":"pola-rs/polars","slug":"dtype-not-yet-supported-in-checked-div","errorCode":null,"errorMessage":"dtype not yet supported in checked div","messagePattern":"dtype not yet supported in checked div","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/series/arithmetic/borrowed.rs","lineNumber":345,"sourceCode":"                    .unwrap()\n                    .apply(|opt_v| {\n                        opt_v.and_then(|v| {\n                            let res = rhs.to_f32().unwrap();\n                            if res.is_zero() { None } else { Some(v / res) }\n                        })\n                    })\n                    .into_series(),\n                Float64 => s\n                    .f64()\n                    .unwrap()\n                    .apply(|opt_v| {\n                        opt_v.and_then(|v| {\n                            let res = rhs.to_f64().unwrap();\n                            if res.is_zero() { None } else { Some(v / res) }\n                        })\n                    })\n                    .into_series(),\n                _ => panic!(\"dtype not yet supported in checked div\"),\n            };\n            out.cast(self.dtype())\n        }\n    }\n}\n\npub fn coerce_lhs_rhs<'a>(\n    lhs: &'a Series,\n    rhs: &'a Series,\n) -> PolarsResult<(Cow<'a, Series>, Cow<'a, Series>)> {\n    if let Some(result) = coerce_time_units(lhs, rhs) {\n        return Ok(result);\n    }\n    let (left_dtype, right_dtype) = (lhs.dtype(), rhs.dtype());\n    let leaf_super_dtype = try_get_supertype(left_dtype.leaf_dtype(), right_dtype.leaf_dtype())?;\n\n    let mut new_left_dtype = left_dtype.cast_leaf(leaf_super_dtype.clone());\n    let mut new_right_dtype = right_dtype.cast_leaf(leaf_super_dtype);","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/pola-rs/polars/blob/9b5d73fd00236295624374b075d16b1fe6ec6df9/crates/polars-core/src/series/arithmetic/borrowed.rs#L327-L363","documentation":"checked_div_num divides a Series by a scalar and is implemented only for the fixed set of numeric dtypes (u8/u16/u32/u64/i8/i16/i32/i64/f32/f64). Any other dtype - Boolean, Utf8, Decimal, Categorical, List, Datetime in some feature sets - falls through to panic 'dtype not yet supported in checked div'.","triggerScenarios":"Calling s.checked_div_num(2) where s holds Boolean, String, Decimal, Categorical, or nested values; also division helpers that internally route scalar division through checked_div_num.","commonSituations":"Applying generic math (e.g. scaling a column) to a column that turned out non-numeric: booleans from a filter, decimal columns from financial data, categorical codes from enum columns.","solutions":["Cast the series to a numeric dtype first: s.cast(&DataType::Float64)?.checked_div_num(2.0)","Use full Series-to-Series checked_div with a broadcast series, which handles more dtypes","Branch on the dtype and reject non-numeric columns with a clear error before dividing"],"exampleFix":"// before\nlet out = s.checked_div_num(2)?;\n\n// after\nlet out = s.cast(&DataType::Float64)?.checked_div_num(2.0)?;","handlingStrategy":"validation","validationCode":"fn is_scalar_divisible(s: &Series) -> bool {\n    use DataType::*;\n    matches!(s.dtype(), Int8|Int16|Int32|Int64|UInt8|UInt16|UInt32|UInt64|Float32|Float64)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cast non-numeric series to Float64/Int64 before checked_div_num","Branch on dtype and reject Boolean/String/Categorical/Decimal columns before scalar math","Centralize 'numeric-only' checks in shared helpers used by all math pipelines"],"tags":["rust","polars","checked-div","unsupported-dtype","panic","arithmetic"],"backgroundTag":"unsupported-dtype-for-operation","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"}