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

snowflake.snowpark.functions.var_samp¶

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

Returns the sample variance of non-NULL records in a group. If all records inside a group are NULL, a NULL is returned. For a single row, NULL is returned as sample variance. Alias of variance()

Example:

>>> df = session.create_dataframe([1, -1, 1, -1, -1], schema=["a"])
>>> df.select(var_samp(col("a"))).collect()
[Row(VARIANCE("A")=Decimal('1.200000'))]

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

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

>>> df = session.create_dataframe([42], schema=["a"])
>>> df.select(var_samp(col("a"))).collect()
[Row(VARIANCE("A")=None)]
Copy