Package tech.tablesaw.aggregate
Class Summarizer
- java.lang.Object
-
- tech.tablesaw.aggregate.Summarizer
-
public class Summarizer extends Object
Summarizes the data in a table, by applying functions to a subset of its columns.How to use:
1. Create an instance providing a source table, the column or columns to summarize, and a function or functions to apply 2. Applying the functions to the designated columns, possibly creating subgroup summaries using one of the by() methods
-
-
Constructor Summary
Constructors Constructor Description Summarizer(Table sourceTable, List<String> columnNames, AggregateFunction<?,?>... functions)
Returns an object capable of summarizing the given column in the given sourceTable, by applying the given functionsSummarizer(Table sourceTable, Column<?> column, AggregateFunction<?,?>... functions)
Returns an object capable of summarizing the given column in the given sourceTable, by applying the given functionsSummarizer(Table sourceTable, Column<?> column1, Column<?> column2, AggregateFunction<?,?>... functions)
Returns an object capable of summarizing the given columns in the given sourceTable, by applying the given functionsSummarizer(Table sourceTable, Column<?> column1, Column<?> column2, Column<?> column3, AggregateFunction<?,?>... functions)
Returns an object capable of summarizing the given column2 in the given sourceTable, by applying the given functionsSummarizer(Table sourceTable, Column<?> column1, Column<?> column2, Column<?> column3, Column<?> column4, AggregateFunction<?,?>... functions)
Returns an object capable of summarizing the given columns in the given sourceTable, by applying the given functions
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Table
apply()
Returns the result of applying to the functions to all the values in the appropriate column TODO add a test that uses a non numeric return type with applyTable
by(int step)
Returns a summary of the records grouped into subsets of the same size, in the order they appearTable
by(String... columnNames)
Similar in intent to the SQL "group by" statement, it produces a table with one row for each subgroup of the output data containing the result of applying the summary functions to the subgroupTable
by(CategoricalColumn<?>... columns)
Similar in intent to the SQL "group by" statement, it produces a table with one row for each subgroup of the output data containing the result of applying the summary functions to the subgroupSummarizer
groupBy(int step)
TODO: research how the groupBy() methods differ from the by() methods? Are they synonyms?Summarizer
groupBy(String... columnNames)
TODO: research how the groupBy() methods differ from the by() methods? Are they synonyms?Summarizer
groupBy(CategoricalColumn<?>... columns)
TODO: research how the groupBy() methods differ from the by() methods? Are they synonyms?Table
having(Function<Table,Selection> selection)
Similar in intent to the SQL having command, it enables the user to apply a filter to the grouped results of summary.
-
-
-
Constructor Detail
-
Summarizer
public Summarizer(Table sourceTable, Column<?> column, AggregateFunction<?,?>... functions)
Returns an object capable of summarizing the given column in the given sourceTable, by applying the given functions
-
Summarizer
public Summarizer(Table sourceTable, List<String> columnNames, AggregateFunction<?,?>... functions)
Returns an object capable of summarizing the given column in the given sourceTable, by applying the given functions
-
Summarizer
public Summarizer(Table sourceTable, Column<?> column1, Column<?> column2, AggregateFunction<?,?>... functions)
Returns an object capable of summarizing the given columns in the given sourceTable, by applying the given functions
-
Summarizer
public Summarizer(Table sourceTable, Column<?> column1, Column<?> column2, Column<?> column3, Column<?> column4, AggregateFunction<?,?>... functions)
Returns an object capable of summarizing the given columns in the given sourceTable, by applying the given functions
-
Summarizer
public Summarizer(Table sourceTable, Column<?> column1, Column<?> column2, Column<?> column3, AggregateFunction<?,?>... functions)
Returns an object capable of summarizing the given column2 in the given sourceTable, by applying the given functions
-
-
Method Detail
-
by
public Table by(String... columnNames)
Similar in intent to the SQL "group by" statement, it produces a table with one row for each subgroup of the output data containing the result of applying the summary functions to the subgroup- Parameters:
columnNames
- The names of the columns to group on- Returns:
- A table containing the grouped results
-
by
public Table by(CategoricalColumn<?>... columns)
Similar in intent to the SQL "group by" statement, it produces a table with one row for each subgroup of the output data containing the result of applying the summary functions to the subgroup- Parameters:
columns
- The columns to group on- Returns:
- A table containing the grouped results
-
by
public Table by(int step)
Returns a summary of the records grouped into subsets of the same size, in the order they appearAll groups have the same number of records. If the final group has fewer than step records it is dropped.
- Parameters:
step
- the number or records to include in each group
-
apply
public Table apply()
Returns the result of applying to the functions to all the values in the appropriate column TODO add a test that uses a non numeric return type with apply
-
having
public Table having(Function<Table,Selection> selection)
Similar in intent to the SQL having command, it enables the user to apply a filter to the grouped results of summary. Only groups that pass the filter are included in the output.- Parameters:
selection
- ASelection
where each index provided refers to a row in the output table- Returns:
- A table of filtered summarized data
-
groupBy
public Summarizer groupBy(CategoricalColumn<?>... columns)
TODO: research how the groupBy() methods differ from the by() methods? Are they synonyms?
-
groupBy
public Summarizer groupBy(String... columnNames)
TODO: research how the groupBy() methods differ from the by() methods? Are they synonyms?
-
groupBy
public Summarizer groupBy(int step)
TODO: research how the groupBy() methods differ from the by() methods? Are they synonyms?
-
-