{"record":{"id":"cd4c6637dfa2ab7b","repo":"pola-rs/polars","slug":"expected-series-in-arg-where-if-eager-true-go","errorCode":null,"errorMessage":"expected Series in 'arg_where' if 'eager=True', got {type(condition).__name__!r}","messagePattern":"expected Series in 'arg_where' if 'eager=True', got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/functions/lazy.py","lineNumber":2468,"sourceCode":"    >>> df.select(\n    ...     [\n    ...         pl.arg_where(pl.col(\"a\") % 2 == 0),\n    ...     ]\n    ... ).to_series()\n    shape: (2,)\n    Series: 'a' [u32]\n    [\n        1\n        3\n    ]\n    \"\"\"\n    if eager:\n        if not isinstance(condition, pl.Series):\n            msg = (\n                \"expected Series in 'arg_where' if 'eager=True', got\"\n                f\" {type(condition).__name__!r}\"\n            )\n            raise ValueError(msg)\n        return condition.to_frame().select(arg_where(F.col(condition.name))).to_series()\n    else:\n        condition_pyexpr = parse_into_expression(condition)\n        return wrap_expr(plr.arg_where(condition_pyexpr))\n\n\n@overload\ndef coalesce(\n    exprs: IntoExpr | Iterable[IntoExpr],\n    *more_exprs: IntoExpr,\n    eager: Literal[False] = ...,\n) -> Expr: ...\n\n\n@overload\ndef coalesce(\n    exprs: IntoExpr | Iterable[IntoExpr],\n    *more_exprs: IntoExpr,","sourceCodeStart":2450,"sourceCodeEnd":2486,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/functions/lazy.py#L2450-L2486","documentation":"Raised by polars.arg_when... polars.arg_where when eager=True but the condition is not a pl.Series (usually it is an Expr or a column name). The eager path immediately evaluates by converting the condition to a one-column DataFrame and selecting arg_where on it, which only works on materialized Series data.","triggerScenarios":"Calling pl.arg_where(pl.col('a') > 1, eager=True); passing a string column name like pl.arg_where('a', eager=True); passing any non-Series object while eager=True.","commonSituations":"Copy-pasting a lazy expression into an eager context; refactoring df.select(pl.arg_where(...)) into a direct call; confusing arg_where with Series.arg_true or DataFrame.filter.","solutions":["Pass a Series condition: pl.arg_where(df['a'] > 1, eager=True)","Drop eager and use the expression inside a context: df.select(pl.arg_where(pl.col('a') > 1))","If you already hold a boolean mask, use mask.arg_true() or df.filter(mask) instead"],"exampleFix":"// before\npl.arg_where(pl.col('a') > 1, eager=True)\n// after\npl.arg_where(df['a'] > 1, eager=True)\n# or keep it lazy:\ndf.select(pl.arg_where(pl.col('a') > 1))","handlingStrategy":"type-guard","validationCode":"import polars as pl\n\nif eager and not isinstance(condition, pl.Series):\n    condition = df[condition.meta.output_name()] if isinstance(condition, pl.Expr) else df[condition]","typeGuard":"def is_polars_series(x) -> bool:\n    return isinstance(x, pl.Series)","tryCatchPattern":"try:\n    out = pl.arg_where(condition, eager=True)\nexcept ValueError:\n    out = df.select(pl.arg_where(condition))  # fall back to lazy evaluation","preventionTips":["Reserve eager=True for calls where you already hold a Series mask","Standardize on df.select(...) for expression-based conditions","Add a thin wrapper that asserts isinstance(condition, pl.Series) when eager=True"],"tags":["polars","eager-execution","expression","type-validation"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}