pivot#

swordfish.function.pivot()#

Rearrange the results of an aggregate function as a matrix.

Assume rowAlignCol has n unique elements and colAlignCol has m unique elements. The template will return an n (row) by m (column) matrix, with unique values of rowAlignCol as row labels and unique values of colAlignCol as column labels. For each element of the matrix, the given function is applied conditional on rowAlignCol and colAlignCol equal to corresponding values indicated by the cell’s row and column labels.

Parameters:
  • func (Constant) – An aggregate function.

  • funcArgs (Constant) – The parameters of func. It is a tuple if there are more than 1 parameter of func.

  • rowAlignCol (Constant) – The grouping variable for the rows of the result.

  • colAlignCol (Constant) – The grouping variable for the columns of the result.