{"record":{"id":"0f02b59ef59a457e","repo":"pola-rs/polars","slug":"expected-at-least-one-series-in-cov-inputs-if-e","errorCode":null,"errorMessage":"expected at least one Series in 'cov' inputs if 'eager=True'","messagePattern":"expected at least one Series in 'cov' inputs if 'eager=True'","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/functions/lazy.py","lineNumber":1067,"sourceCode":"    ╞═════╪═════╡\n    │ 3.0 ┆ 6.0 │\n    └─────┴─────┘\n\n    Eager evaluation:\n\n    >>> s1 = pl.Series(\"a\", [1, 8, 3])\n    >>> s2 = pl.Series(\"b\", [4, 5, 2])\n    >>> pl.cov(s1, s2, eager=True)\n    shape: (1,)\n    Series: 'a' [f64]\n    [\n        3.0\n    ]\n    \"\"\"\n    if eager:\n        if not (isinstance(a, pl.Series) or isinstance(b, pl.Series)):\n            msg = \"expected at least one Series in 'cov' inputs if 'eager=True'\"\n            raise ValueError(msg)\n\n        frame = pl.DataFrame([e for e in (a, b) if isinstance(e, pl.Series)])\n        exprs = ((e.name if isinstance(e, pl.Series) else e) for e in (a, b))\n        return frame.select(cov(*exprs, eager=False, ddof=ddof)).to_series()\n    else:\n        a_pyexpr = parse_into_expression(a)\n        b_pyexpr = parse_into_expression(b)\n        return wrap_expr(plr.cov(a_pyexpr, b_pyexpr, ddof))\n\n\nclass _map_batches_wrapper:\n    def __init__(\n        self,\n        function: Callable[[Sequence[Series]], Series | Any],\n        *,\n        returns_scalar: bool,\n    ) -> None:\n        self.function = function","sourceCodeStart":1049,"sourceCodeEnd":1085,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/functions/lazy.py#L1049-L1085","documentation":"pl.cov(..., eager=True) builds a one-shot DataFrame from the Series inputs and returns the covariance as a scalar Series. If neither a nor b is a pl.Series (both are Exprs or bare column names) there is no data to compute over, so ValueError is raised before evaluation.","triggerScenarios":"pl.cov('a', 'b', eager=True); pl.cov(pl.col('a'), pl.col('b'), eager=True) outside select; converting a df.select(pl.cov(...)) snippet into a standalone call with eager=True.","commonSituations":"Summary/statistics helpers that switched from context-based to eager evaluation; quick notebooks referencing columns by name only.","solutions":["Pass Series: pl.cov(df['a'], df['b'], eager=True)","Or evaluate in context: df.select(pl.cov('a', 'b')).item()","Mixed Series + Expr is fine — the expression is evaluated against the Series' frame"],"exampleFix":"# before\npl.cov('a', 'b', eager=True)  # ValueError\n\n# after\npl.cov(df['a'], df['b'], eager=True)\n# or\ndf.select(pl.cov('a', 'b')).item()","handlingStrategy":"validation","validationCode":"if eager and not (isinstance(a, pl.Series) or isinstance(b, pl.Series)):\n    result = df.select(pl.cov(a, b, ddof=ddof)).item()\nelse:\n    result = pl.cov(a, b, eager=eager, ddof=ddof)","typeGuard":"def has_series_input(a, b) -> bool:\n    return isinstance(a, pl.Series) or isinstance(b, pl.Series)","tryCatchPattern":null,"preventionTips":["Pass Series (df['a']) when using eager=True; keep names/Exprs for select() contexts","Remember ddof still applies to cov — validate it too when wrapping the API"],"tags":["polars","cov","eager","input-validation"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}