pola-rs/polars · error · ValueError
more schema overrides are specified than there are selected…
Error message
more schema overrides are specified than there are selected columns
What it means
Validation in read_csv: when columns are selected (by name or via new_columns) and schema_overrides is given as a list, its length must not exceed the number of selected columns — each dtype would map to a column that will not exist. Trim the overrides list to match the selection.
Solutions
- Provide no more schema overrides than the number of selected columns, or widen the column selection.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at py-polars/src/polars/io/csv/functions.py:422 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pola-rs/polars@68506541d2 (2026-08-19).
Data as JSON: /api/errors/89cec8a2d8844e24.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/io/csv/functions.py:422
# pyarrow auto-generates names 'f0', 'f1', ... when there is no
# header, so index N maps to name 'fN'.
include_columns = [f"f{column_idx}" for column_idx in projection]
else:
# With a header, real names come from row 1 and aren't known
# until after the read. Leave the filter off and slice the
# Table by position later.
include_columns = None
with prepare_file_arg( # type: ignore[no-matching-overload]
source, # type: ignore[arg-type]
encoding=None,
use_pyarrow=True,
raise_if_empty=raise_if_empty,
storage_options=storage_options,
) as data:
import pyarrow as pa
import pyarrow.csv
try:
tbl = pa.csv.read_csv(
data,
pa.csv.ReadOptions(
skip_rows=skip_rows,
skip_rows_after_names=skip_rows_after_header,
autogenerate_column_names=not has_header,
encoding=encoding,
),
pa.csv.ParseOptions(
delimiter=separator,
quote_char=quote_char if quote_char else False,
double_quote=quote_char is not None and quote_char == '"',
),
pa.csv.ConvertOptions(
column_types=None,
include_columns=include_columns,
include_missing_columns=ignore_errors,View on GitHub (pinned to 68506541d2)