snowflake.snowpark.functions.regr_avgy¶

snowflake.snowpark.functions.regr_avgy(y: Union[Column, str], x: Union[Column, str]) → Column[source]¶

Returns the average of the dependent variable for non-null pairs in a group, where x is the independent variable and y is the dependent variable.

Example:

>>> df = session.create_dataframe([[10, 11], [20, 22], [25, None], [30, 35]], schema=["v", "v2"])
>>> df = df.group_by("v").agg(regr_avgy(df["v"], df["v2"]).alias("regr_avgy"))
>>> df.collect()
[Row(V=10, REGR_AVGY=10.0), Row(V=20, REGR_AVGY=20.0), Row(V=25, REGR_AVGY=None), Row(V=30, REGR_AVGY=30.0)]
Copy