covar_samp
Renvoie une nouvelle colonne pour la covariance échantillon de col1 et col2.
Syntaxe
Python
from pyspark.sql import functions as sf
sf.covar_samp(col1, col2)
parameter
parameter | Type | Description |
|---|---|---|
|
| Première colonne pour calculer la covariance. |
|
| Deuxième colonne pour calculer la covariance. |
Renvoie
pyspark.sql.Column: covariance d'échantillon de ces deux valeurs de colonne.
Exemples
Python
from pyspark.sql import functions as sf
a = [1] * 10
b = [1] * 10
df = spark.createDataFrame(zip(a, b), ["a", "b"])
df.agg(sf.covar_samp("a", df.b)).show()
Output
+----------------+
|covar_samp(a, b)|
+----------------+
| 0.0|
+----------------+