Class PivotTable

java.lang.Object
tech.tablesaw.aggregate.PivotTable

public class PivotTable extends Object
PivotTable is used to 'rotate' a source table such that it is summarized on the values of some column. As implemented here, you supply: - a "key" categorical column from which the primary grouping is created, there will be one on each row of the result - a second categorical column for which a subtotal is created; this produces n columns on each row of the result - one column for each unique value - a numeric column that provides the values to be summarized - an aggregation function that defines what operation is performed on the values in the subgroups
  • Method Details

    • pivot

      public static Table pivot(Table table, CategoricalColumn<?> column1, CategoricalColumn<?> column2, NumericColumn<?> values, AggregateFunction<?,?> aggregateFunction)
      Returns a table that is a rotation of the given table pivoted around the key columns, and filling the output cells using the values calculated by the aggregateFunction when applied to the values column grouping by the key columns
      Parameters:
      table - The table that provides the data to be pivoted
      column1 - A "key" categorical column from which the primary grouping is created. There will be one on each row of the result
      column2 - A second categorical column for which a subtotal is created; this produces n columns on each row of the result
      values - A numeric column that provides the values to be summarized
      aggregateFunction - function that defines what operation is performed on the values in the subgroups
      Returns:
      A new, pivoted table