pyspark.sql.functions.covar_samp

pyspark.sql.functions.covar_samp(col1: ColumnOrName, col2: ColumnOrName) → pyspark.sql.column.Column

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

Examples

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