pyspark.sql.functions.covar_pop

pyspark.sql.functions.covar_pop(col1: ColumnOrName, col2: ColumnOrName) → pyspark.sql.column.Column[source]

Returns a new Column for the population covariance of col1 and col2.

New in version 2.0.0.

Examples

>>> a = [1] * 10
>>> b = [1] * 10
>>> df = spark.createDataFrame(zip(a, b), ["a", "b"])
>>> df.agg(covar_pop("a", "b").alias('c')).collect()
[Row(c=0.0)]