{"record":{"id":"62fc96410c67a86a","repo":"pola-rs/polars","slug":"expected-at-least-one-series-in-corr-inputs-if","errorCode":null,"errorMessage":"expected at least one Series in 'corr' inputs if 'eager=True'","messagePattern":"expected at least one Series in 'corr' inputs if 'eager=True'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/functions/lazy.py","lineNumber":940,"sourceCode":"    >>> s1 = pl.Series(\"a\", [1, 8, 3])\n    >>> s2 = pl.Series(\"b\", [4, 5, 2])\n    >>> pl.corr(s1, s2, eager=True)\n    shape: (1,)\n    Series: 'a' [f64]\n    [\n        0.544705\n    ]\n    >>> pl.corr(s1, s2, method=\"spearman\", eager=True)\n    shape: (1,)\n    Series: 'a' [f64]\n    [\n        0.5\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 'corr' 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(\n            corr(*exprs, eager=False, method=method, propagate_nans=propagate_nans)\n        ).to_series()\n    else:\n        a_pyexpr = parse_into_expression(a)\n        b_pyexpr = parse_into_expression(b)\n\n        if method == \"pearson\":\n            return wrap_expr(plr.pearson_corr(a_pyexpr, b_pyexpr))\n        elif method == \"spearman\":\n            return wrap_expr(plr.spearman_rank_corr(a_pyexpr, b_pyexpr, propagate_nans))\n        else:\n            msg = f\"method must be one of {{'pearson', 'spearman'}}, got {method!r}\"\n            raise ValueError(msg)\n","sourceCodeStart":922,"sourceCodeEnd":958,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/functions/lazy.py#L922-L958","documentation":"`pl.corr(a, b, eager=True)` builds a DataFrame from whichever inputs are Series; if neither `a` nor `b` is a Series there is no frame to compute on, so it raises ValueError. In eager mode at least one input must be a concrete Series; strings/expressions are only allowed alongside one.","triggerScenarios":"Calling `pl.corr(\"a\", \"b\", eager=True)` with two string column names, or two Exprs, while `eager=True`.","commonSituations":"Copy-pasting lazy-style string column names into an eager call; assuming eager mode resolves column names like the lazy API does.","solutions":["Pass at least one `pl.Series` to `corr` when using `eager=True`","Drop `eager=True` and use `df.select(pl.corr(\"a\", \"b\"))` for string/expr inputs","Convert a column to a Series first: `df[\"a\"]`"],"exampleFix":"// before\npl.corr(\"a\", \"b\", eager=True)\n// after\npl.corr(df[\"a\"], df[\"b\"], eager=True)\n# or lazily:\ndf.select(pl.corr(\"a\", \"b\"))","handlingStrategy":"type-guard","validationCode":"if eager and not (isinstance(a, pl.Series) or isinstance(b, pl.Series)):\n    raise TypeError(\"corr(eager=True) needs at least one pl.Series\")","typeGuard":"def corr_eager_ok(a, b): return isinstance(a, pl.Series) or isinstance(b, pl.Series)","tryCatchPattern":"try:\n    return pl.corr(a, b, eager=True)\nexcept ValueError:\n    return df.select(pl.corr(a, b)).to_series()","preventionTips":["Prefer the lazy form df.select(pl.corr(...)) unless eager is required","Convert columns to Series explicitly before eager calls","Check the signature docstring for eager-mode input requirements"],"tags":["python","polars","dataframe","arguments"],"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"}