org.apache.spark.sql
Class DataFrameStatFunctions

Object
  extended by org.apache.spark.sql.DataFrameStatFunctions

public final class DataFrameStatFunctions
extends Object

:: Experimental :: Statistic functions for DataFrames.

Since:
1.4.0

Method Summary
 double corr(String col1, String col2)
          Calculates the Pearson Correlation Coefficient of two columns of a DataFrame.
 double corr(String col1, String col2, String method)
          Calculates the correlation of two columns of a DataFrame.
 double cov(String col1, String col2)
          Calculate the sample covariance of two numerical columns of a DataFrame.
 DataFrame crosstab(String col1, String col2)
          Computes a pair-wise frequency table of the given columns.
 DataFrame freqItems(scala.collection.Seq<String> cols)
          (Scala-specific) Finding frequent items for columns, possibly with false positives.
 DataFrame freqItems(scala.collection.Seq<String> cols, double support)
          (Scala-specific) Finding frequent items for columns, possibly with false positives.
 DataFrame freqItems(String[] cols)
          Finding frequent items for columns, possibly with false positives.
 DataFrame freqItems(String[] cols, double support)
          Finding frequent items for columns, possibly with false positives.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

cov

public double cov(String col1,
                  String col2)
Calculate the sample covariance of two numerical columns of a DataFrame.

Parameters:
col1 - the name of the first column
col2 - the name of the second column
Returns:
the covariance of the two columns.

Since:
1.4.0

corr

public double corr(String col1,
                   String col2,
                   String method)
Calculates 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.

Parameters:
col1 - the name of the column
col2 - the name of the column to calculate the correlation against
method - (undocumented)
Returns:
The Pearson Correlation Coefficient as a Double.

Since:
1.4.0

corr

public double corr(String col1,
                   String col2)
Calculates the Pearson Correlation Coefficient of two columns of a DataFrame.

Parameters:
col1 - the name of the column
col2 - the name of the column to calculate the correlation against
Returns:
The Pearson Correlation Coefficient as a Double.

Since:
1.4.0

crosstab

public DataFrame crosstab(String col1,
                          String col2)
Computes a pair-wise frequency table of the given columns. Also known as a contingency table. The number of distinct values for each column should be less than 1e4. At most 1e6 non-zero pair frequencies will be returned. The first column of each row will be the distinct values of col1 and the column names will be the distinct values of col2. The name of the first column will be $col1_$col2. Counts will be returned as Longs. Pairs that have no occurrences will have null as their counts. Null elements will be replaced by "null", and back ticks will be dropped from elements if they exist.

Parameters:
col1 - The name of the first column. Distinct items will make the first item of each row.
col2 - The name of the second column. Distinct items will make the column names of the DataFrame.
Returns:
A DataFrame containing for the contingency table.

Since:
1.4.0

freqItems

public DataFrame freqItems(String[] cols,
                           double support)
Finding frequent items for columns, possibly with false positives. Using the frequent element count algorithm described in http://dx.doi.org/10.1145/762471.762473, proposed by Karp, Schenker, and Papadimitriou. The support should be greater than 1e-4.

This function is meant for exploratory data analysis, as we make no guarantee about the backward compatibility of the schema of the resulting DataFrame.

Parameters:
cols - the names of the columns to search frequent items in.
support - The minimum frequency for an item to be considered frequent. Should be greater than 1e-4.
Returns:
A Local DataFrame with the Array of frequent items for each column.

Since:
1.4.0

freqItems

public DataFrame freqItems(String[] cols)
Finding frequent items for columns, possibly with false positives. Using the frequent element count algorithm described in http://dx.doi.org/10.1145/762471.762473, proposed by Karp, Schenker, and Papadimitriou. Uses a default support of 1%.

This function is meant for exploratory data analysis, as we make no guarantee about the backward compatibility of the schema of the resulting DataFrame.

Parameters:
cols - the names of the columns to search frequent items in.
Returns:
A Local DataFrame with the Array of frequent items for each column.

Since:
1.4.0

freqItems

public DataFrame freqItems(scala.collection.Seq<String> cols,
                           double support)
(Scala-specific) Finding frequent items for columns, possibly with false positives. Using the frequent element count algorithm described in http://dx.doi.org/10.1145/762471.762473, proposed by Karp, Schenker, and Papadimitriou.

This function is meant for exploratory data analysis, as we make no guarantee about the backward compatibility of the schema of the resulting DataFrame.

Parameters:
cols - the names of the columns to search frequent items in.
support - (undocumented)
Returns:
A Local DataFrame with the Array of frequent items for each column.

Since:
1.4.0

freqItems

public DataFrame freqItems(scala.collection.Seq<String> cols)
(Scala-specific) Finding frequent items for columns, possibly with false positives. Using the frequent element count algorithm described in http://dx.doi.org/10.1145/762471.762473, proposed by Karp, Schenker, and Papadimitriou. Uses a default support of 1%.

This function is meant for exploratory data analysis, as we make no guarantee about the backward compatibility of the schema of the resulting DataFrame.

Parameters:
cols - the names of the columns to search frequent items in.
Returns:
A Local DataFrame with the Array of frequent items for each column.

Since:
1.4.0