{"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":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/functions/lazy.py","lineNumber":2312,"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":2294,"sourceCodeEnd":2330,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/functions/lazy.py#L2294-L2330","documentation":"`pl.arg_where(condition, eager=True)` requires `condition` to be a boolean `pl.Series`, since eager mode evaluates immediately against a concrete mask. Any other type (list, Expr, string) raises ValueError including the offending type name.","triggerScenarios":"Calling `pl.arg_where([True, False, True], eager=True)` with a Python list, or passing an Expr/string with `eager=True`.","commonSituations":"Passing plain Python lists/arrays instead of Series; mixing lazy expression API with eager flag.","solutions":["Convert the input: `pl.Series([True, False, True])`","Drop `eager=True` and use `df.select(pl.arg_where(pl.col(\"mask\")))` for expr inputs","Ensure the Series is boolean dtype"],"exampleFix":"// before\npl.arg_where([True, False], eager=True)\n// after\npl.arg_where(pl.Series([True, False]), eager=True)","handlingStrategy":"type-guard","validationCode":"def arg_where_eager(cond):\n    if not isinstance(cond, pl.Series):\n        cond = pl.Series(cond)\n    return pl.arg_where(cond, eager=True)","typeGuard":"def arg_where_eager_ok(c): return isinstance(c, pl.Series)","tryCatchPattern":"try:\n    return pl.arg_where(cond, eager=True)\nexcept ValueError:\n    return pl.arg_where(pl.Series(cond), eager=True)","preventionTips":["Convert lists/arrays to pl.Series before eager calls","Verify the mask is boolean dtype","Use lazy select form for expression inputs"],"tags":["python","polars","eager","type-mismatch"],"backgroundTag":"invalid-argument-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}