pyspark.sql.functions.var_samp

pyspark.sql.functions.var_samp(col: ColumnOrName) → pyspark.sql.column.Column[source]

Aggregate function: returns the unbiased sample variance of the values in a group.

New in version 1.6.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
colColumn or str

target column to compute on.

Returns
Column

variance of given column.

Examples

>>> df = spark.range(6)
>>> df.select(var_samp(df.id)).show()
+------------+
|var_samp(id)|
+------------+
|         3.5|
+------------+