{"record":{"id":"6a5303146bd11ef7","repo":"pola-rs/polars","slug":"invalid-name-nm-r","errorCode":null,"errorMessage":"invalid name: {nm!r}","messagePattern":"invalid name: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/selectors.py","lineNumber":1283,"sourceCode":"    shape: (2, 2)\n    ┌─────┬───────┐\n    │ baz ┆ zap   │\n    │ --- ┆ ---   │\n    │ f64 ┆ bool  │\n    ╞═════╪═══════╡\n    │ 2.0 ┆ false │\n    │ 5.5 ┆ true  │\n    └─────┴───────┘\n    \"\"\"\n    all_names = []\n    for nm in names:\n        if isinstance(nm, str):\n            all_names.append(nm)\n        elif isinstance(nm, Collection):\n            for n in nm:\n                if not isinstance(n, str):\n                    msg = f\"invalid name: {n!r}\"\n                    raise TypeError(msg)\n                all_names.append(n)\n        else:\n            msg = f\"invalid name: {nm!r}\"\n            raise TypeError(msg)\n\n    return Selector._by_name(all_names, strict=require_all, expand_patterns=False)\n\n\ndef empty() -> Selector:\n    \"\"\"\n    Select no columns.\n\n    This is useful for composition with other selectors.\n\n    See Also\n    --------\n    all : Select all columns in the current scope.\n","sourceCodeStart":1265,"sourceCodeEnd":1301,"githubUrl":"https://github.com/pola-rs/polars/blob/68506541d2de983056c9eb244e1ea05fab377dfc/py-polars/src/polars/selectors.py#L1265-L1301","documentation":"cs.by_name validates `names`: top-level strings are accepted, collections are flattened, and any item inside a collection that is not a str triggers this TypeError naming the bad name. It fires when a non-string (e.g. an int column reference) is nested inside the names argument.","triggerScenarios":"Thrown at py-polars/src/polars/selectors.py:1291 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a valid string name for the selector/index operation."],"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"}