contextby#
- swordfish.function.contextby()#
Calculate func(funcArgs) for each groupingCol group.
- Parameters:
func (Constant) – A function. For the second use case, func can only have one parameter (funcArg).
funcArgs (Constant) – The parameters of func. It is a tuple if there are more than 1 parameter of func.
groupingCol (The vectors in) – The grouping variable(s). It can be one or multiple vectors.
sortingCol (Constant) – An optional argument for within group sorting before applying func.
semanticFilter (Constant, optional) –
A positive integer indicating which columns to include in calculations when funcArgs is a table. The possible values are:
0 - All columns
1 (default) - Columns of FLOATING, INTEGRAL, and DECIMAL categories, excluding the COMPRESSED data type.
2 - Columns of TEMPORAL category.
3 - Columns of LITERAL category, excluding the BLOB data type.
4 - Columns of FLOATING, INTEGRAL, DECIMAL, and TEMPORAL categories, excluding the COMPRESSED data type.
groupingCol
size. (sortingCol and each of the function argument in funcArgs all have the same)
- Returns:
A vector of the same size as each of the input arguments other than func. If func is an aggregate function, all elements within the same group have identical result. We can use sortingCol to sort the within-group data before the calculation.
Note
The keyword defg must be used to declare an aggregate function.
- Return type: