{"record":{"id":"66f6e3ab345c124c","repo":"pola-rs/polars","slug":"names-is-not-a-sequence","errorCode":null,"errorMessage":"`names` is not a sequence","messagePattern":"`names` is not a sequence","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/interchange/dataframe.py","lineNumber":158,"sourceCode":"            indices = list(indices)\n\n        return PolarsDataFrame(\n            self._df[:, indices],\n            allow_copy=self._allow_copy,\n        )\n\n    def select_columns_by_name(self, names: Sequence[str]) -> PolarsDataFrame:\n        \"\"\"\n        Create a new dataframe by selecting a subset of columns by name.\n\n        Parameters\n        ----------\n        names\n            Column names.\n        \"\"\"\n        if not isinstance(names, Sequence):\n            msg = \"`names` is not a sequence\"\n            raise TypeError(msg)\n\n        return PolarsDataFrame(\n            self._df.select(names),\n            allow_copy=self._allow_copy,\n        )\n\n    def get_chunks(self, n_chunks: int | None = None) -> Iterator[PolarsDataFrame]:\n        \"\"\"\n        Return an iterator yielding the chunks of the dataframe.\n\n        Parameters\n        ----------\n        n_chunks\n            The number of chunks to return. Must be a multiple of the number of chunks\n            in the dataframe. If set to `None` (default), returns all chunks.\n\n        Notes\n        -----","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/pola-rs/polars/blob/9b5d73fd00236295624374b075d16b1fe6ec6df9/py-polars/src/polars/interchange/dataframe.py#L140-L176","documentation":"Type-guard in PolarsDataFrame.select_columns_by_name: the interchange protocol requires column names as a Sequence[str]; passing a bare string (which is itself a Sequence of chars, hence the explicit check), an int, or an iterator triggers this TypeError. Pass a list of name strings.","triggerScenarios":"Thrown at py-polars/src/polars/interchange/dataframe.py:158 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass names as a sequence of strings (e.g. a list) rather than a single string or non-sequence value."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9b5d73fd00236295624374b075d16b1fe6ec6df9","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}