{"record":{"id":"b6c27334f231bc69","repo":"pola-rs/polars","slug":"indices-is-not-a-sequence","errorCode":null,"errorMessage":"`indices` is not a sequence","messagePattern":"`indices` is not a sequence","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/interchange/dataframe.py","lineNumber":138,"sourceCode":"        return PolarsColumn(s, allow_copy=self._allow_copy)\n\n    def get_columns(self) -> Iterator[PolarsColumn]:\n        \"\"\"Return an iterator yielding the columns.\"\"\"\n        for column in self._df.get_columns():\n            yield PolarsColumn(column, allow_copy=self._allow_copy)\n\n    def select_columns(self, indices: Sequence[int]) -> PolarsDataFrame:\n        \"\"\"\n        Create a new dataframe by selecting a subset of columns by index.\n\n        Parameters\n        ----------\n        indices\n            Column indices\n        \"\"\"\n        if not isinstance(indices, Sequence):\n            msg = \"`indices` is not a sequence\"\n            raise TypeError(msg)\n        if not isinstance(indices, list):\n            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):","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/pola-rs/polars/blob/9b5d73fd00236295624374b075d16b1fe6ec6df9/py-polars/src/polars/interchange/dataframe.py#L120-L156","documentation":"Type-guard in PolarsDataFrame.select_columns: the interchange protocol requires the column indices to be a Sequence[int]; passing a single int, an iterator, or another non-sequence triggers this TypeError. Wrap the value in a list before calling.","triggerScenarios":"Thrown at py-polars/src/polars/interchange/dataframe.py:138 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass indices as a sequence (e.g. a list or range of integers) instead of a scalar 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"}