Github user rxin commented on a diff in the pull request:
https://github.com/apache/spark/pull/5858#discussion_r29544396
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/DataFrameStatFunctions.scala ---
@@ -28,6 +28,32 @@ import org.apache.spark.sql.execution.stat._
final class DataFrameStatFunctions private[sql](df: DataFrame) {
/**
+ * Calculate the correlation of two columns of a DataFrame. Currently
only supports the Pearson
+ * Correlation Coefficient. For Spearman Correlation, consider using RDD
methods found in
+ * MLlib's Statistics.
+ *
+ * @param col1 the name of the column
+ * @param col2 the name of the column to calculate the correlation
against
+ * @return The Pearson Correlation Coefficient as a Double.
+ */
+ def corr(col1: String, col2: String, method: String): Double = {
+ assert(method == "pearson", "Currently only the calculation of the
Pearson Correlation " +
+ "coefficient is supported.")
+ StatFunctions.pearsonCorrelation(df, Seq(col1, col2))
+ }
+
+ /**
+ * Java Friendly implementation to calculate the Pearson correlation
coefficient of two columns.
--- End diff --
what's not java friendly?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]