pyspark.sql.functions.variance#

pyspark.sql.functions.variance(col)[source]#

Aggregate function: alias for var_samp

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(variance(df.id)).show()
+------------+
|variance(id)|
+------------+
|         3.5|
+------------+