{"record":{"id":"d89247c022ad2653","repo":"pola-rs/polars","slug":"column-must-be-a-series-or-expr-got-column-r-t","errorCode":null,"errorMessage":"column must be a Series or Expr, got {column!r} (type={qualified_type_name(column)})","messagePattern":"column must be a Series or Expr, got (.+?) \\(type=(.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/dataframe/frame.py","lineNumber":5388,"sourceCode":"            if index < 0:\n                msg = f\"column index {original_index} is out of range (frame has {self.width} columns)\"\n                raise IndexError(msg)\n        elif index > self.width:\n            msg = f\"column index {original_index} is out of range (frame has {self.width} columns)\"\n            raise IndexError(msg)\n\n        if isinstance(column, pl.Series):\n            self._df.insert_column(index, column._s)\n        else:\n            if isinstance(column, str):\n                column = F.col(column)\n            if isinstance(column, pl.Expr):\n                cols = self.columns\n                cols.insert(index, column)  # type: ignore[arg-type]\n                self._df = self.select(cols)._df\n            else:\n                msg = f\"column must be a Series or Expr, got {column!r} (type={qualified_type_name(column)})\"\n                raise TypeError(msg)\n        return self\n\n    def filter(\n        self,\n        *predicates: (\n            IntoExprColumn\n            | Iterable[IntoExprColumn]\n            | bool\n            | list[bool]\n            | np.ndarray[Any, Any]\n        ),\n        **constraints: Any,\n    ) -> DataFrame:\n        \"\"\"\n        Filter rows, retaining those that match the given predicate expression(s).\n\n        The original order of the remaining rows is preserved.\n","sourceCodeStart":5370,"sourceCodeEnd":5406,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/dataframe/frame.py#L5370-L5406","documentation":"Error \"column must be a Series or Expr, got {column!r} (type={qualified_type_name(column)})\" thrown in pola-rs/polars.","triggerScenarios":"Thrown at py-polars/src/polars/dataframe/frame.py:5388 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}