{"record":{"id":"abe14e015e0ad8e2","repo":"pola-rs/polars","slug":"more-new-column-names-are-specified-than-there-are","errorCode":null,"errorMessage":"more new column names are specified than there are selected columns","messagePattern":"more new column names are specified than there are selected columns","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/csv/functions.py","lineNumber":456,"sourceCode":"                        column_types=None,\n                        include_columns=include_columns,\n                        include_missing_columns=ignore_errors,\n                    ),\n                )\n            except pa.ArrowInvalid as err:\n                if raise_if_empty or \"Empty CSV\" not in str(err):\n                    raise\n                return pl.DataFrame()\n\n        if not has_header:\n            # Rename 'f0', 'f1', ... columns names autogenerated by pyarrow\n            # to 'column_0', 'column_1', ...\n            tbl = tbl.rename_columns(\n                [f\"column_{int(column[1:])}\" for column in tbl.column_names]\n            )\n        elif not column_names and projection:\n            # User selected columns by positional index (e.g. `columns=[0, 2]`).\n            # pyarrow's include_columns only accepts names, so the read above\n            # fetched every column; pick out the requested positions now.\n            tbl = tbl.select(list(projection))\n\n        df = pl.DataFrame._from_arrow(tbl)\n\n        if new_columns:\n            return _update_columns(df, new_columns)\n\n        if row_index is not None:\n            name, offset = row_index\n            df = df.with_row_index(name, offset)\n\n        return df\n\n    def _scan(source: Any, encoding: CsvEncoding | str) -> pl.LazyFrame:\n        return scan_csv(\n            source,\n            has_header=has_header,","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/pola-rs/polars/blob/68506541d2de983056c9eb244e1ea05fab377dfc/py-polars/src/polars/io/csv/functions.py#L438-L474","documentation":"Validation in read_csv: new_columns (renaming list) is longer than the set of columns actually selected via `columns`. There would be more new names than columns to apply them to. Make the two lists the same length.","triggerScenarios":"Thrown at py-polars/src/polars/io/csv/functions.py:456 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide no more new column names than the number of selected columns."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"68506541d2de983056c9eb244e1ea05fab377dfc","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}