{"record":{"id":"c66d23bea4398c79","repo":"pola-rs/polars","slug":"the-dtypes-parameter-for-read-csv-has-been-ren","errorCode":null,"errorMessage":"the `dtypes` parameter for `read_csv` has been renamed to `schema_overrides`.","messagePattern":"the `dtypes` parameter for `read_csv` has been renamed to `schema_overrides`\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/spreadsheet/functions.py","lineNumber":930,"sourceCode":"    drop_empty_cols: bool,\n    raise_if_empty: bool,\n) -> pl.DataFrame:\n    \"\"\"Translate StringIO buffer containing delimited data as a DataFrame.\"\"\"\n    # handle (completely) empty sheet data\n    if csv.tell() == 0:\n        return _empty_frame(raise_if_empty)\n\n    # otherwise rewind the buffer and parse as csv\n    csv.seek(0)\n\n    if read_options is None:\n        read_options = {}\n\n    date_cols = []\n    if schema_overrides:\n        if csv_dtypes := read_options.get(\"dtypes\", {}):\n            msg = \"the `dtypes` parameter for `read_csv` has been renamed to `schema_overrides`.\"\n            raise TypeError(msg)\n\n        csv_schema_overrides = cast(\n            \"SchemaDict\", read_options.get(\"schema_overrides\", csv_dtypes)\n        )\n        if set(csv_schema_overrides).intersection(schema_overrides):\n            msg = \"cannot specify columns in both `schema_overrides` and `read_options['dtypes']`\"\n            raise ParameterCollisionError(msg)\n\n        overrides, schema_overrides = {**csv_schema_overrides, **schema_overrides}, {}\n        for nm, dtype in overrides.items():\n            if dtype != Date:\n                schema_overrides[nm] = dtype\n            else:\n                date_cols.append(nm)\n\n        read_options = read_options.copy()\n        read_options[\"schema_overrides\"] = schema_overrides\n","sourceCodeStart":912,"sourceCodeEnd":948,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/spreadsheet/functions.py#L912-L948","documentation":"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`.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Rename the key from `dtypes` to `schema_overrides` inside `read_options`.","If you passed a top-level `schema_overrides` to read_excel, merge your per-column types into it instead of using read_options['dtypes'].","Update any shared wrappers to use the new read_csv parameter name."],"exampleFix":"// before\npl.read_excel('f.xlsx', engine='xlsx2csv', read_options={'dtypes': {'id': pl.Int64}})\n// after\npl.read_excel('f.xlsx', engine='xlsx2csv', read_options={'schema_overrides': {'id': pl.Int64}})","handlingStrategy":"validation","validationCode":"FORBIDDEN = {'dtypes'}\nbad = read_options.keys() & FORBIDDEN\nif bad:\n    raise ValueError(f'rename {bad} to schema_overrides in read_options')","typeGuard":null,"tryCatchPattern":"try:\n    df = pl.read_excel(path, engine='xlsx2csv', read_options=read_options)\nexcept TypeError as e:\n    if 'renamed to `schema_overrides`' in str(e):\n        read_options = {('schema_overrides' if k == 'dtypes' else k): v for k, v in read_options.items()}\n        df = pl.read_excel(path, engine='xlsx2csv', read_options=read_options)\n    else:\n        raise","preventionTips":["After upgrading polars, grep for read_options={'dtypes'} and migrate","Use top-level schema_overrides instead of read_options for column dtypes","Pin polars in CI and run tests that exercise spreadsheet reads"],"tags":["polars","excel","renamed-parameter","deprecated-api"],"backgroundTag":"deprecated-api-usage","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"}