You are viewing documentation about an older version (1.1.0). View latest version

snowflake.snowpark.DataFrameStatFunctions.corr

DataFrameStatFunctions.corr(col1: ColumnOrName, col2: ColumnOrName, *, statement_params: Dict[str, str] | None = None) float | None[source]

Calculates the correlation coefficient for non-null pairs in two numeric columns.

Example:

>>> df = session.create_dataframe([[0.1, 0.5], [0.2, 0.6], [0.3, 0.7]], schema=["a", "b"])
>>> df.stat.corr("a", "b")
0.9999999999999991
Copy
Parameters:
  • col1 – The name of the first numeric column to use.

  • col2 – The name of the second numeric column to use.

  • statement_params – Dictionary of statement level parameters to be set while executing this action.

Returns:

The correlation of the two numeric columns. If there is not enough data to generate the correlation, the method returns None. statement_params: Dictionary of statement level parameters to be set while executing this action.