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

snowflake.snowpark.functions.covar_samp¶

snowflake.snowpark.functions.covar_samp(column1: Union[Column, str], column2: Union[Column, str]) → Column[source]¶

Returns the sample 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_samp(col("a"), col("b")).cast(DecimalType(scale=3)).alias("result")).show()
------------
|"RESULT"  |
------------
|2.300     |
------------
Copy