Skip to content

Commit 1b8f920

Browse files
committed
Simplify covar
1 parent aca9d13 commit 1b8f920

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

python/datafusion/functions.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,17 +2115,15 @@ def covar_pop(value_y: Expr, value_x: Expr, filter: Expr | None = None) -> Expr:
21152115
---------
21162116
>>> import builtins
21172117
>>> ctx = dfn.SessionContext()
2118-
>>> df = ctx.from_pydict({"a": [1.0, 2.0, 3.0], "b": [4.0, 5.0, 6.0]})
2118+
>>> df = ctx.from_pydict({"a": [1.0, 2.0, 3.0], "b": [1.0, 2.0, 3.0]})
21192119
>>> result = df.aggregate(
21202120
... [],
21212121
... [dfn.functions.covar_pop(
21222122
... dfn.col("a"), dfn.col("b")
21232123
... ).alias("v")]
21242124
... )
2125-
>>> builtins.round(
2126-
... result.collect_column("v")[0].as_py(), 4
2127-
... )
2128-
0.6667
2125+
>>> result.collect_column("v")[0].as_py() == 1.
2126+
True
21292127
"""
21302128
filter_raw = filter.expr if filter is not None else None
21312129
return Expr(f.covar_pop(value_y.expr, value_x.expr, filter=filter_raw))

0 commit comments

Comments
 (0)