polars.spearman_rank_corr#
- polars.spearman_rank_corr(a: str | Expr, b: str | Expr, ddof: int = 1, *, propagate_nans: bool = False) Expr [source]#
Compute the spearman rank correlation between two columns.
Missing data will be excluded from the computation.
Deprecated since version 0.16.10:
spearman_rank_corr
will be removed in favor ofcorr(..., method="spearman")
.- Parameters:
- a
Column name or Expression.
- b
Column name or Expression.
- ddof
Delta degrees of freedom
- propagate_nans
If True any NaN encountered will lead to NaN in the output. Defaults to False where NaN are regarded as larger than any finite number and thus lead to the highest rank.
See also
Examples
>>> df = pl.DataFrame({"a": [1, 8, 3], "b": [4, 5, 2], "c": ["foo", "bar", "foo"]}) >>> df.select(pl.spearman_rank_corr("a", "b")) shape: (1, 1) ┌─────┐ │ a │ │ --- │ │ f64 │ ╞═════╡ │ 0.5 │ └─────┘