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

snowflake.snowpark.functions.var_pop¶

snowflake.snowpark.functions.var_pop(e: Union[Column, str]) → Column[source]¶

Returns the population variance of non-NULL records in a group. If all records inside a group are NULL, a NULL is returned. The population variance of a single row is 0.0.

Example:

>>> df = session.create_dataframe([1, -1, 1, -1, -1], schema=["a"])
>>> df.select(var_pop(col("a"))).collect()
[Row(VAR_POP("A")=Decimal('0.960000'))]

>>> df = session.create_dataframe([1, None, 2, 3, None, 5, 6], schema=["a"])
>>> df.select(var_pop(col("a"))).collect()
[Row(VAR_POP("A")=Decimal('3.440000'))]

>>> df = session.create_dataframe([None, None, None], schema=["a"])
>>> df.select(var_pop(col("a"))).collect()
[Row(VAR_POP("A")=None)]

>>> df = session.create_dataframe([42], schema=["a"])
>>> df.select(var_pop(col("a"))).collect()
[Row(VAR_POP("A")=Decimal('0.000000'))]
Copy