CovarPop
This class calculates the population or sample covariance between two numeric expressions. It allows for optional filtering of input rows and provides a mechanism to specify a default value when no data is available.
Attributes
| Attribute | Type | Description |
|---|---|---|
| function | string | The SQL aggregate function name used for calculation, determined by whether the covariance is for a sample or a population. |
Constructor
Signature
def CovarPop(
y: Any,
x: Any,
sample: boolean = False,
filter: Any = None,
default: Any = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| y | Any | The dependent variable or first expression for covariance calculation. |
| x | Any | The independent variable or second expression for covariance calculation. |
| sample | boolean = False | If True, uses COVAR_SAMP; otherwise, uses COVAR_POP. |
| filter | Any = None | An optional filter expression to limit the rows included in the aggregate. |
| default | Any = None | The default value to return if no rows are aggregated. |
Signature
def CovarPop(
y: expression,
x: expression,
sample: boolean = False,
filter: expression = None,
default: any = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| y | expression | The dependent variable expression used as the first argument in the covariance calculation |
| x | expression | The independent variable expression used as the second argument in the covariance calculation |
| sample | boolean = False | Determines whether to calculate sample covariance (COVAR_SAMP) instead of the default population covariance (COVAR_POP) |
| filter | expression = None | An optional boolean condition used to filter the rows included in the aggregate calculation |
| default | any = None | The value to return if the calculation result is null or if no rows match the filter criteria |