{"record":{"id":"d94d38639e6c1811","repo":"pola-rs/polars","slug":"from-repr-does-not-support-data-type-dtype-base","errorCode":null,"errorMessage":"`from_repr` does not support data type {dtype.base_type().__name__!r}","messagePattern":"`from_repr` does not support data type (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/convert/general.py","lineNumber":1014,"sourceCode":"            if coldata:\n                coldata.pop(idx)\n\n    # init cols as String Series, handle \"null\" -> None, create schema from repr dtype\n    data = [\n        pl.Series([(None if v in (\"null\", \"NULL\") else v) for v in cd], dtype=String)\n        for cd in coldata\n    ]\n    schema = dict(zip(headers, (_dtype_from_name(d) for d in dtypes), strict=True))\n    if schema and data and (n_extend_cols := (len(schema) - len(data))) > 0:\n        empty_data = [None] * len(data[0])\n        data.extend((pl.Series(empty_data, dtype=String)) for _ in range(n_extend_cols))\n\n    for dtype in set(schema.values()):\n        if dtype is not None and (dtype.is_nested() or dtype.is_object()):\n            msg = (\n                f\"`from_repr` does not support data type {dtype.base_type().__name__!r}\"\n            )\n            raise NotImplementedError(msg)\n\n    # Deal with line wrapping by detecting columns which may not be empty, but are\n    # anyway, indicating a wrap has occurred.\n    str_schema = [(k, String) for k in schema]\n    tmp_df = pl.DataFrame(data=data, orient=\"col\", schema=str_schema)\n    out_rows: list[Series] = []\n    for row_list in tmp_df.iter_rows():\n        row = pl.Series(row_list, dtype=String)\n        if out_rows and any(\n            col == \"\" and dtype is not None and dtype != String and dtype != Categorical\n            for col, dtype in zip(row, schema.values(), strict=True)\n        ):\n            pad = pl.Series(\n                [\n                    \"\" if x == \"\" or y == \"\" else \" \"\n                    for x, y in zip(out_rows[-1], row, strict=True)\n                ],\n                dtype=String,","sourceCodeStart":996,"sourceCodeEnd":1032,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/convert/general.py#L996-L1032","documentation":"`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.","triggerScenarios":"Calling `from_repr` on a DataFrame repr whose dtype line includes nested or object dtypes such as `list[i64]`, `struct[...]`, or `object`.","commonSituations":"Copying a repr of a DataFrame containing list/struct columns or Python objects; attempting to round-trip complex-typed frames through text.","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."],"exampleFix":"// before\npl.from_repr(repr_with_list_column)\n// after\ndf.drop('nested_col').to_file('df.parquet')  # round-trip nested data via Parquet","handlingStrategy":"fallback","validationCode":"import polars as pl\nnested = [c for c, d in df.schema.items() if d.is_nested() or d.is_object()]\nassert not nested, f'from_repr cannot round-trip: {nested}'","typeGuard":null,"tryCatchPattern":"try:\n    df = pl.from_repr(s)\nexcept NotImplementedError:\n    df = pl.read_parquet('snapshot.parquet')  # structural round-trip","preventionTips":["Serialize nested-typed frames with Parquet/IPC/JSON instead of reprs","Cast list/struct columns to strings before printing if reprs are needed"],"tags":["python","polars","not-implemented","dtypes"],"backgroundTag":"unsupported-operation","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"}