{"record":{"id":"a0073647bc67d57c","repo":"pola-rs/polars","slug":"invalid-input-for-exclude-n-nexpected-one-or-mor","errorCode":null,"errorMessage":"invalid input for `exclude`\\n\\nExpected one or more `str` or `DataType`; found {item!r} instead.","messagePattern":"invalid input for `exclude`\\\\n\\\\nExpected one or more `str` or `DataType`; found (.+?) instead\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/selectors.py","lineNumber":578,"sourceCode":"        exclude_dtypes: builtins.list[PolarsDataType] = []\n        for item in (\n            *(\n                columns\n                if isinstance(columns, Collection) and not isinstance(columns, str)\n                else [columns]\n            ),\n            *more_columns,\n        ):\n            if isinstance(item, str):\n                exclude_cols.append(item)\n            elif is_polars_dtype(item):\n                exclude_dtypes.append(item)\n            else:\n                msg = (\n                    \"invalid input for `exclude`\"\n                    f\"\\n\\nExpected one or more `str` or `DataType`; found {item!r} instead.\"\n                )\n                raise TypeError(msg)\n\n        if exclude_cols and exclude_dtypes:\n            msg = \"cannot exclude by both column name and dtype\"\n            raise TypeError(msg)\n\n        excluded = (\n            by_dtype(exclude_dtypes)\n            if exclude_dtypes\n            else Selector._by_name(\n                exclude_cols,\n                strict=False,\n                expand_patterns=True,\n            )\n        )\n        return self - excluded\n\n    def as_expr(self) -> Expr:\n        \"\"\"","sourceCodeStart":560,"sourceCodeEnd":596,"githubUrl":"https://github.com/pola-rs/polars/blob/68506541d2de983056c9eb244e1ea05fab377dfc/py-polars/src/polars/selectors.py#L560-L596","documentation":"selectors.exclude() validates every item in `columns`/`more_columns`: strings go to exclude_cols and polars dtypes to exclude_dtypes. This generic TypeError guard fires for any other input type (e.g. an int, a function, or a nested non-string value) passed to exclude(), telling you exactly which offending item was rejected.","triggerScenarios":"Thrown at py-polars/src/polars/selectors.py:586 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass str names or DataType instances to exclude; other types are invalid."],"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"}