{"record":{"id":"9157e468ebeba5c4","repo":"pola-rs/polars","slug":"method-must-be-one-of-pearson-spearman-g","errorCode":null,"errorMessage":"method must be one of {{'pearson', 'spearman'}}, got {method!r}","messagePattern":"method must be one of (.+?)\\}, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/functions/lazy.py","lineNumber":957,"sourceCode":"            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\n\n@overload\ndef cov(\n    a: IntoExpr,\n    b: IntoExpr,\n    *,\n    ddof: int = ...,\n    eager: Literal[False] = ...,\n) -> Expr: ...\n\n\n@overload\ndef cov(\n    a: IntoExpr,\n    b: IntoExpr,\n    *,\n    ddof: int = ...,","sourceCodeStart":939,"sourceCodeEnd":975,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/functions/lazy.py#L939-L975","documentation":"`pl.corr` only supports 'pearson' and 'spearman' correlation methods; any other string reaches the final else branch and raises ValueError. The f-string uses doubled braces so the message shows the literal set of valid methods.","triggerScenarios":"Calling `pl.corr(a, b, method=\"spearman rank\")`, `method=\"Pearson\"` (case-sensitive), or any other misspelled/unsupported method string.","commonSituations":"Case mistakes ('Pearson'), confusion with other libraries' method strings (e.g. pandas accepts 'kendall' — polars does not), typos.","solutions":["Use exactly 'pearson' or 'spearman' (lowercase)","Check for case/typo errors in the method argument","Implement other correlations (e.g. kendall) outside polars if needed"],"exampleFix":"// before\npl.corr(\"a\", \"b\", method=\"Pearson\")\n// after\npl.corr(\"a\", \"b\", method=\"pearson\")","handlingStrategy":"validation","validationCode":"VALID_CORR_METHODS = {\"pearson\", \"spearman\"}\nif method not in VALID_CORR_METHODS:\n    raise ValueError(f\"method must be one of {VALID_CORR_METHODS}\")","typeGuard":"def is_valid_corr_method(m): return isinstance(m, str) and m in {\"pearson\", \"spearman\"}","tryCatchPattern":null,"preventionTips":["Keep method strings in a module-level constant","Remember polars does not support 'kendall'","Lowercase user-supplied method strings before passing"],"tags":["python","polars","dataframe","invalid-enum"],"backgroundTag":"invalid-enum-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"}