snowflake.snowpark.functions.regr_valx¶

snowflake.snowpark.functions.regr_valx(y: Union[snowflake.snowpark.column.Column, str], x: Union[snowflake.snowpark.column.Column, str]) → Column[source]¶

Returns None if either argument is None; otherwise, returns the second argument. Note that REGR_VALX is a None-preserving function, while the more commonly-used NVL is a None-replacing function.

Parameters:
  • y (ColumnOrName) – The dependent variable column.

  • x (ColumnOrName) – The independent variable column.

Returns:

The result of the regr_valx function.

Return type:

Column

Example:

>>> from snowflake.snowpark import Row
>>> df = session.create_dataframe([[2.0, 1.0], [None, 3.0], [6.0, None]], schema=["col_y", "col_x"])
>>> result = df.select(regr_valx(df["col_y"], df["col_x"]).alias("result")).collect()
>>> assert result == [Row(RESULT=1.0), Row(RESULT=None), Row(RESULT=None)]

Important: Note the order of the arguments; y precedes x
Copy