{"record":{"id":"cb61066a40b480be","repo":"pola-rs/polars","slug":"to-list-not-implemented-for-unknown","errorCode":null,"errorMessage":"to_list not implemented for unknown","messagePattern":"to_list not implemented for unknown","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-python/src/series/export.rs","lineNumber":161,"sourceCode":"                        iter: RepeatN<Option<u8>>,\n                        n: usize,\n                    }\n                    impl Iterator for NullIter {\n                        type Item = Option<u8>;\n\n                        fn next(&mut self) -> Option<Self::Item> {\n                            self.iter.next()\n                        }\n                        fn size_hint(&self) -> (usize, Option<usize>) {\n                            (self.n, Some(self.n))\n                        }\n                    }\n                    impl ExactSizeIterator for NullIter {}\n\n                    PyList::new(py, NullIter { iter, n })?\n                },\n                DataType::Unknown(_) => {\n                    panic!(\"to_list not implemented for unknown\")\n                },\n                DataType::BinaryOffset => {\n                    unreachable!()\n                },\n                DataType::Map(_, _) => {\n                    let ca = series.map().map_err(PyPolarsErr::from)?;\n                    PyList::new(py, ca.any_value_iter().map(Wrap))?\n                },\n                DataType::Extension(_, _) => {\n                    return to_list_recursive(py, series.ext().unwrap().storage());\n                },\n            };\n            Ok(pylist.into_any())\n        }\n\n        to_list_recursive(py, series)\n    }\n","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-python/src/series/export.rs#L143-L179","documentation":"to_list_recursive converts a Series into nested Python objects. DataType::Unknown represents a dtype that could not be resolved (typically an unresolved lazy/dynamic dtype or plugin output), and there is no Python representation for it, so the code panics with 'to_list not implemented for unknown'.","triggerScenarios":"Calling Series.to_list() on a column whose dtype is DataType::Unknown — commonly produced by plugin expression outputs, failed dtype resolution in lazy frames, or experimental dtype paths.","commonSituations":"After collect() of a lazy frame using plugin/functions whose return dtype was not resolved; deserialized or cached lazy plans with unresolved dtypes; polars version mismatches between client and plugin.","solutions":["Resolve the dtype before to_list: cast the column to a concrete dtype, e.g. df['col'].cast(pl.String).to_list().","Fix the producing expression so it declares a concrete output_dtype (set return_dtype in map_elements or the plugin function).","Upgrade polars and any polars plugins to matching versions to avoid Unknown dtypes from deserialization.","Use .to_pandas() or .to_numpy() only after the dtype is resolved; inspect df.schema to find the Unknown column."],"exampleFix":"# before\ndf['mystery'].to_list()  # dtype is Unknown -> panic\n# after\nprint(df.schema)  # find Unknown column\nprint(df['mystery'].cast(pl.String).to_list())","handlingStrategy":"validation","validationCode":"unknown_cols = [n for n, dt in df.schema.items() if dt == pl.Unknown or str(dt) == 'unknown']\nassert not unknown_cols, f'unresolved dtypes in: {unknown_cols}'","typeGuard":"def has_resolved_dtypes(df):\n    return all(str(dt) != 'unknown' for dt in df.schema.values())","tryCatchPattern":"try:\n    vals = df['col'].to_list()\nexcept BaseException as e:\n    if 'not implemented for unknown' in str(e):\n        vals = df['col'].cast(pl.String).to_list()\n    else:\n        raise","preventionTips":["Inspect df.schema after collect() on lazy frames with plugins.","Always specify return_dtype/output_dtype in map_elements and plugin calls.","Keep polars and plugin versions in sync."],"tags":["python","dtype","panic","lazyframe","to-list"],"backgroundTag":"unsupported-dtype","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}