pyspark.sql.functions.covar_samp#
- pyspark.sql.functions.covar_samp(col1, col2)[source]#
Returns a new
Column
for the sample covariance ofcol1
andcol2
.New in version 2.0.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- Returns
Column
sample covariance of these two column values.
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)]