snowflake.snowpark.functions.covar_pop

snowflake.snowpark.functions.covar_pop(column1: Union[Column, str], column2: Union[Column, str]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/functions.py#L894-L913)

Returns the population covariance for non-null pairs in a group.

Example

>>> from snowflake.snowpark.types import DecimalType
>>> df = session.create_dataframe([[1, 2], [1, 2], [4, 5], [2, 3], [3, None], [4, None], [6,4]], schema=["a", "b"])
>>> df.select(covar_pop(col("a"), col("b")).cast(DecimalType(scale=3)).alias("result")).show()
------------
|"RESULT"  |
------------
|1.840     |
------------
Copy
Language: English