public class DataFrameStatFunctions extends Object
To access an object of this class, use DataFrame.stat().
| Modifier and Type | Method and Description |
|---|---|
Optional<Double>[][] |
approxQuantile(String[] cols,
double[] percentile)
For an array of numeric columns and an array of desired quantiles, returns a matrix of
approximate values for each column at each of the desired quantiles.
|
Optional<Double>[] |
approxQuantile(String col,
double[] percentile)
For a specified numeric column and an array of desired quantiles, returns an approximate value
for the column at each of the desired quantiles.
|
Optional<Double> |
corr(String col1,
String col2)
Calculates the correlation coefficient for non-null pairs in two numeric columns.
|
Optional<Double> |
cov(String col1,
String col2)
Calculates the sample covariance for non-null pairs in two numeric columns.
|
DataFrame |
crosstab(String col1,
String col2)
Computes a pair-wise frequency table (a ''contingency table'') for the specified columns.
|
DataFrame |
sampleBy(Column col,
Map<?,Double> fractions)
Returns a DataFrame containing a stratified sample without replacement, based on a Map that
specifies the fraction for each stratum.
|
DataFrame |
sampleBy(String colName,
Map<?,Double> fractions)
Returns a DataFrame containing a stratified sample without replacement, based on a Map that
specifies the fraction for each stratum.
|
public Optional<Double> corr(String col1, String col2)
col1 - The name of the first numeric column to use.col2 - The name of the second numeric column to use.public Optional<Double> cov(String col1, String col2)
col1 - The name of the first numeric column to use.col2 - The name of the second numeric column to use.public Optional<Double>[] approxQuantile(String col, double[] percentile)
This function uses the t-Digest algorithm.
col - The name of the numeric column.percentile - An array of double values greater than or equal to 0.0 and less than 1.0.public Optional<Double>[][] approxQuantile(String[] cols, double[] percentile)
This function uses the t-Digest algorithm.
cols - An array of column names.percentile - An array of double values greater than or equal to 0.0 and less than 1.0.public DataFrame crosstab(String col1, String col2)
In the returned contingency table:
- The first column of each row contains the distinct values of col1. - The name of
the first column is the name of col1. - The rest of the column names are the distinct
values of col2. - The counts are returned as Longs. - For pairs that have no
occurrences, the contingency table contains 0 as the count.
Note: The number of distinct values in col2 should not exceed 1000.
col1 - The name of the first column to use.col2 - The name of the second column to use.public DataFrame sampleBy(Column col, Map<?,Double> fractions)
col - An expression for the column that defines the strata.fractions - A Map that specifies the fraction to use for the sample for each stratum. If a
stratum is not specified in the Map, the method uses 0 as the fraction.public DataFrame sampleBy(String colName, Map<?,Double> fractions)
colName - The name of the column that defines the strata.fractions - A Map that specifies the fraction to use for the sample for each stratum. If a
stratum is not specified in the Map, the method uses 0 as the fraction.© 2022 Snowflake Inc. All Rights Reserved