{"record":{"id":"21ffc0c8c95b8b4b","repo":"pola-rs/polars","slug":"cannot-specify-columns-in-both-schema-overrides","errorCode":null,"errorMessage":"cannot specify columns in both `schema_overrides` and `read_options['dtypes']`","messagePattern":"cannot specify columns in both `schema_overrides` and `read_options\\['dtypes'\\]`","errorType":"exception","errorClass":"ParameterCollisionError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/spreadsheet/functions.py","lineNumber":937,"sourceCode":"\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\n    df = _drop_null_data(\n        df=read_csv(\n            csv,\n            separator=separator,\n            **read_options,\n        ),\n        raise_if_empty=raise_if_empty,","sourceCodeStart":919,"sourceCodeEnd":955,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/spreadsheet/functions.py#L919-L955","documentation":"This ParameterCollisionError fires when the same column(s) get a dtype from two places at once: the top-level `schema_overrides` argument of read_excel and `read_options['schema_overrides']` (formerly `dtypes`) forwarded to the internal read_csv call via the xlsx2csv path. Polars refuses the ambiguous overlapping specification rather than guessing which wins.","triggerScenarios":"`pl.read_excel(..., engine='xlsx2csv', schema_overrides={'col': pl.Utf8}, read_options={'schema_overrides'/'dtypes': {'col': pl.Int64}})` where the key sets intersect (set intersection is non-empty).","commonSituations":"Merging user-supplied options dicts with defaults that both contain column dtype maps; passing schema_overrides at both levels after migrating from the old `dtypes` name; helper functions that blindly forward kwargs.","solutions":["Remove the column dtype map from `read_options` and specify all overrides in the top-level `schema_overrides` parameter.","Or keep overrides only in read_options and drop the top-level schema_overrides — pick one location.","Ensure the key sets are disjoint if you genuinely need both (different columns in each)."],"exampleFix":"// before\npl.read_excel('f.xlsx', engine='xlsx2csv', schema_overrides={'a': pl.Utf8}, read_options={'schema_overrides': {'a': pl.Int64}})\n// after\npl.read_excel('f.xlsx', engine='xlsx2csv', schema_overrides={'a': pl.Utf8})","handlingStrategy":"validation","validationCode":"ro = read_options.get('schema_overrides', {})\noverlap = set(schema_overrides or {}).keys() & set(ro).keys()\nif overlap:\n    raise ValueError(f'column dtype overrides specified twice: {sorted(overlap)}')","typeGuard":null,"tryCatchPattern":"try:\n    df = pl.read_excel(path, engine='xlsx2csv', schema_overrides=overrides, read_options=read_options)\nexcept pl.exceptions.ParameterCollisionError as e:\n    log.error('Duplicate column overrides: %s', e)\n    raise","preventionTips":["Specify column dtypes in exactly one place (prefer top-level schema_overrides)","When merging option dicts, merge their schema_overrides maps explicitly and check for key collisions","Write a small wrapper function that owns all read_options construction"],"tags":["polars","excel","conflicting-options"],"backgroundTag":"conflicting-config-options","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"}