Grouping and Aggregation
A grouping is a collection of keys and sets of indexes into a dataset. Each element of the grouping corresponds to a subset (i.e. a group of observations) of a dataset. Groups may overlap. Moving windows and partitions are examples of groupings.
A grouping is most commonly used in combination with one or more aggregators. An aggregator is a function that reduces one or more vectors to a single value, like the sum or the mean of the elements or the correlation between two vectors. Using an aggregator in combination with a grouping on a data frame, matrix or vector results in a new data frame, matrix or vector with the aggregator applied to each group. The grouping's index becomes the (row) index of the resulting collection. Aggregators can also be used without groupings to reduce an entire data frame, matrix or vector to a single vector or value.
For dataframe work, the modern aggregation workflow uses immutable aggregation descriptors. Descriptor-based dataframe aggregation wraps the existing AggregatorGroup and BinaryAggregatorGroup primitives in user-facing requests that select columns, name outputs, and bind to a data frame. See Aggregating data frames for descriptor examples.
In this section: