pola-rs/polars · error
`from_repr` does not support data type
Error message
`from_repr` does not support data type {dtype.base_type().__name__!r} What it means
`pl.from_repr` builds a schema from the dtype short-reprs shown in the table. Nested dtypes (e.g. List, Struct, Array) and Object columns cannot be represented textually, so a NotImplementedError is raised when the parsed schema contains them.
Solutions
- Avoid repr round-trips for nested data; serialize to JSON/Parquet/IPC and read it back instead.
- Cast nested columns to strings before printing if only the flat columns are needed, then reconstruct those.
- Drop or exclude nested/object columns from the repr you feed to from_repr.
Example fix
// before
pl.from_repr(repr_with_list_column)
// after
df.drop('nested_col').to_file('df.parquet') # round-trip nested data via Parquet Defensive patterns
Strategy: fallback
Validate before calling
import polars as pl
nested = [c for c, d in df.schema.items() if d.is_nested() or d.is_object()]
assert not nested, f'from_repr cannot round-trip: {nested}' Try / catch
try:
df = pl.from_repr(s)
except NotImplementedError:
df = pl.read_parquet('snapshot.parquet') # structural round-trip Prevention
- Serialize nested-typed frames with Parquet/IPC/JSON instead of reprs
- Cast list/struct columns to strings before printing if reprs are needed
When it happens
Trigger: Calling `from_repr` on a DataFrame repr whose dtype line includes nested or object dtypes such as `list[i64]`, `struct[...]`, or `object`.
Common situations: Copying a repr of a DataFrame containing list/struct columns or Python objects; attempting to round-trip complex-typed frames through text.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- `collect_all_async` is not supported by
- `collect_all` is not supported by
- `collect_async` is not supported by
- `collect_batches` is not supported by
- only ufuncs that return one 1D array are supported
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/d94d38639e6c1811.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/convert/general.py:1014
if coldata:
coldata.pop(idx)
# init cols as String Series, handle "null" -> None, create schema from repr dtype
data = [
pl.Series([(None if v in ("null", "NULL") else v) for v in cd], dtype=String)
for cd in coldata
]
schema = dict(zip(headers, (_dtype_from_name(d) for d in dtypes), strict=True))
if schema and data and (n_extend_cols := (len(schema) - len(data))) > 0:
empty_data = [None] * len(data[0])
data.extend((pl.Series(empty_data, dtype=String)) for _ in range(n_extend_cols))
for dtype in set(schema.values()):
if dtype is not None and (dtype.is_nested() or dtype.is_object()):
msg = (
f"`from_repr` does not support data type {dtype.base_type().__name__!r}"
)
raise NotImplementedError(msg)
# Deal with line wrapping by detecting columns which may not be empty, but are
# anyway, indicating a wrap has occurred.
str_schema = [(k, String) for k in schema]
tmp_df = pl.DataFrame(data=data, orient="col", schema=str_schema)
out_rows: list[Series] = []
for row_list in tmp_df.iter_rows():
row = pl.Series(row_list, dtype=String)
if out_rows and any(
col == "" and dtype is not None and dtype != String and dtype != Categorical
for col, dtype in zip(row, schema.values(), strict=True)
):
pad = pl.Series(
[
"" if x == "" or y == "" else " "
for x, y in zip(out_rows[-1], row, strict=True)
],
dtype=String,View on GitHub (pinned to fe841f959e)