snowflake.snowpark.functions.regr_avgx

snowflake.snowpark.functions.regr_avgx(y: Union[Column, str], x: Union[Column, str]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.29.1/snowpark-python/src/snowflake/snowpark/functions.py#L11158-L11172)

Returns the average of the independent 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.groupBy("v").agg(regr_avgx(df["v"], df["v2"]).alias("regr_avgx")).collect()
[Row(V=10, REGR_AVGX=11.0), Row(V=20, REGR_AVGX=22.0), Row(V=25, REGR_AVGX=None), Row(V=30, REGR_AVGX=35.0)]
Copy
Language: English