You are viewing documentation about an older version (1.3.0). View latest version

snowflake.snowpark.functions.covar_pop¶

snowflake.snowpark.functions.covar_pop(column1: ColumnOrName, column2: ColumnOrName) → Column[source]¶

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