pola-rs/polars · error · TypeError

the `dtypes` parameter for `read_csv` has been renamed to…

Error message

the `dtypes` parameter for `read_csv` has been renamed to `schema_overrides`.

What it means

When reading a spreadsheet via the xlsx2csv engine, polars converts the sheet to CSV and then calls `read_csv` with `read_options`. If the user put the old, renamed `dtypes` key into `read_options`, `_csv_buffer_to_frame` raises this TypeError to force migration to the new name, since `read_csv`'s `dtypes` parameter was renamed to `schema_overrides`.

Solutions

  1. Rename the key from `dtypes` to `schema_overrides` inside `read_options`.
  2. If you passed a top-level `schema_overrides` to read_excel, merge your per-column types into it instead of using read_options['dtypes'].
  3. Update any shared wrappers to use the new read_csv parameter name.

Example fix

// before
pl.read_excel('f.xlsx', engine='xlsx2csv', read_options={'dtypes': {'id': pl.Int64}})
// after
pl.read_excel('f.xlsx', engine='xlsx2csv', read_options={'schema_overrides': {'id': pl.Int64}})
Defensive patterns

Strategy: validation

Validate before calling

FORBIDDEN = {'dtypes'}
bad = read_options.keys() & FORBIDDEN
if bad:
    raise ValueError(f'rename {bad} to schema_overrides in read_options')

Try / catch

try:
    df = pl.read_excel(path, engine='xlsx2csv', read_options=read_options)
except TypeError as e:
    if 'renamed to `schema_overrides`' in str(e):
        read_options = {('schema_overrides' if k == 'dtypes' else k): v for k, v in read_options.items()}
        df = pl.read_excel(path, engine='xlsx2csv', read_options=read_options)
    else:
        raise

Prevention

When it happens

Trigger: Calling `pl.read_excel(..., engine='xlsx2csv', read_options={'dtypes': {...}})` — the legacy `dtypes` key is detected inside read_options while schema_overrides was also given at the top level.

Common situations: Upgrading polars after the read_csv API rename and keeping old read_options dicts; copy-pasting pre-rename snippets from blogs or Stack Overflow; shared helper code built against old polars versions.

Understand the failure class

Background: "is deprecated and will be removed" — deprecation warnings for old API names, keywords, and options, and how to migrate before the removal release — this error's family across 29 libraries.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/c66d23bea4398c79. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/src/polars/io/spreadsheet/functions.py:930

    drop_empty_cols: bool,
    raise_if_empty: bool,
) -> pl.DataFrame:
    """Translate StringIO buffer containing delimited data as a DataFrame."""
    # handle (completely) empty sheet data
    if csv.tell() == 0:
        return _empty_frame(raise_if_empty)

    # otherwise rewind the buffer and parse as csv
    csv.seek(0)

    if read_options is None:
        read_options = {}

    date_cols = []
    if schema_overrides:
        if csv_dtypes := read_options.get("dtypes", {}):
            msg = "the `dtypes` parameter for `read_csv` has been renamed to `schema_overrides`."
            raise TypeError(msg)

        csv_schema_overrides = cast(
            "SchemaDict", read_options.get("schema_overrides", csv_dtypes)
        )
        if set(csv_schema_overrides).intersection(schema_overrides):
            msg = "cannot specify columns in both `schema_overrides` and `read_options['dtypes']`"
            raise ParameterCollisionError(msg)

        overrides, schema_overrides = {**csv_schema_overrides, **schema_overrides}, {}
        for nm, dtype in overrides.items():
            if dtype != Date:
                schema_overrides[nm] = dtype
            else:
                date_cols.append(nm)

        read_options = read_options.copy()
        read_options["schema_overrides"] = schema_overrides

View on GitHub (pinned to fe841f959e)