{"record":{"id":"c2f1c8d6adba002e","repo":"pola-rs/polars","slug":"not-implemented-c2f1c8","errorCode":null,"errorMessage":"not implemented","messagePattern":"not implemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-ops/src/chunked_array/list/sum_mean.rs","lineNumber":207,"sourceCode":"        .downcast_iter()\n        .map(|arr| {\n            let offsets = arr.offsets().as_slice();\n            let values = arr.values().as_ref();\n\n            match inner_type {\n                Int8 => dispatch_mean::<i8, f64>(values, offsets, arr.validity()),\n                Int16 => dispatch_mean::<i16, f64>(values, offsets, arr.validity()),\n                Int32 => dispatch_mean::<i32, f64>(values, offsets, arr.validity()),\n                Int64 => dispatch_mean::<i64, f64>(values, offsets, arr.validity()),\n                Int128 => dispatch_mean::<i128, f64>(values, offsets, arr.validity()),\n                UInt8 => dispatch_mean::<u8, f64>(values, offsets, arr.validity()),\n                UInt16 => dispatch_mean::<u16, f64>(values, offsets, arr.validity()),\n                UInt32 => dispatch_mean::<u32, f64>(values, offsets, arr.validity()),\n                UInt64 => dispatch_mean::<u64, f64>(values, offsets, arr.validity()),\n                UInt128 => dispatch_mean::<u128, f64>(values, offsets, arr.validity()),\n                Float32 => dispatch_mean::<f32, f32>(values, offsets, arr.validity()),\n                Float64 => dispatch_mean::<f64, f64>(values, offsets, arr.validity()),\n                _ => unimplemented!(),\n            }\n        })\n        .collect::<Vec<_>>();\n\n    Series::try_from((ca.name().clone(), chunks)).unwrap()\n}\n\npub(super) fn mean_with_nulls(ca: &ListChunked) -> Series {\n    match ca.inner_dtype() {\n        #[cfg(feature = \"dtype-f16\")]\n        DataType::Float16 => {\n            let out: Float16Chunked = ca\n                .apply_amortized_generic(|s| {\n                    use num_traits::FromPrimitive;\n\n                    s.and_then(|s| s.as_ref().mean().map(|v| pf16::from_f64(v).unwrap()))\n                })\n                .with_name(ca.name().clone());","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/crates/polars-ops/src/chunked_array/list/sum_mean.rs#L189-L225","documentation":"mean_list_numerical (the fast path for list.mean()) dispatches on the inner dtype and only enumerates integer/float primitives from i8 through f64; the catch-all arm is a bare unimplemented!(). Because is_primitive_numeric() includes Float16, a List(Float16) column selects this fast path and then panics - Float16 is the realistic gap.","triggerScenarios":"Calling .mean() on a Series/expression of dtype List(Float16): df.select(pl.col(\"f16_lists\").list.mean()).","commonSituations":"Half-precision embeddings or ML feature lists stored as f16 to save memory, then aggregated with list.mean() without casting.","solutions":["Cast the list column's inner dtype to Float32 before taking the mean: pl.col(\"x\").cast(pl.List(pl.Float32)).list.mean()","Enable/verify the dtype-f16 aware slow path by using sum/mean fallbacks that handle nulls (mean_with_nulls handles Float16 when nulls are present)","Upgrade polars - Float16 support in list aggregations is progressively being filled in"],"exampleFix":"# before\ndf.select(pl.col(\"f16_lists\").list.mean())  # List(Float16) -> panic\n\n# after\ndf.select(\n    pl.col(\"f16_lists\").cast(pl.List(pl.Float32)).list.mean()\n)","handlingStrategy":"validation","validationCode":"def list_mean_supported(s: pl.Series) -> bool:\n    inner = s.dtype.inner if isinstance(s.dtype, pl.List) else None\n    return inner is not None and inner != pl.Float16 and not isinstance(inner, pl.Float16)","typeGuard":"def mean_ready_list(s: pl.Series) -> pl.Series:\n    if isinstance(s.dtype, pl.List) and s.dtype.inner == pl.Float16:\n        return s.cast(pl.List(pl.Float32))\n    return s","tryCatchPattern":null,"preventionTips":["Cast List(Float16) columns to List(Float32) before aggregations","Test f16 pipelines against list.mean()/sum() explicitly"],"tags":["rust","polars","panic","unimplemented","list","mean","float16","aggregation"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}