byColumn#

swordfish.function.byColumn()#

If func is a unary function, apply the specified function to each column of X; if func is a binary function, apply func(Xi, Yi) to each column of X and Y.

Calculation rules:

  • If X/Y is a matrix, table, or tuple, byColumn applies func to each column of X/Y.

  • If X/Y is an array vector or columnar tuple, byRow applies func to each row of the transpose of X/Y.

  • If func is a vector function, byColumn returns the transpose of the result.

  • If func is an aggregate function, byColumn directly returns a vector. Certain aggregate functions in DolphinDB are optimized to work natively by column, requiring no transpose of the input X/Y. These include: sum, sum2, avg, min, max, count, imax, imin, imaxLast, iminLast, prod, std, stdp, var, varp, skew, kurtosis, any, all, corr, covar, wavg, wsum, beta, euclidean, dot, tanimoto.

Parameters:
  • func (Constant) – A unary function. When function with multiple parameters is specified for func, partial application is used to fix part of the parameters. It can be a vector function (where the input vector and output vector are of equal length) or an aggregate function.

  • X (Constant) – A matrix/table/tuple/array vector/columnar tuple.

  • Y (Constant, optional) – A matrix/table/tuple/array vector/columnar tuple, by default DFLT

Returns:

If func is an aggregate function:

  • If X/Y is a matrix, array vector, or columnar tuple, byColumn returns a vector of the same size as the number of columns in X/Y.

  • If X/Y is a tuple, byColumn returns a tuple.

  • If X/Y is a table, byColumn returns a table.

If func is a vector function, byColumn returns a result with the same form and dimension as X/Y.

Return type:

Constant