AggregationStatistics

GroupBy aggregation statistics

Provides predefined shortcuts for the most common statistical aggregation operations that can be applied to each group within a GroupBy.

Each function computes a statistic across the rows of a group and returns the result as a new column (or several columns) in the resulting DataFrame.

  • count — calculate the number of rows in each group (optionally counting only rows that satisfy the given predicate);

  • countDistinct — calculate the number of distinct rows in each group (or distinct combinations of values in selected columns);

  • max / maxOf / maxFor — calculate the maximum of all values on the selected columns / by a row expression / for each of the selected columns within each group;

  • min / minOf / minFor — calculate the minimum of all values on the selected columns / by a row expression / for each of the selected columns within each group;

  • sum / sumOf / sumFor — calculate the sum of all values on the selected columns / by a row expression / for each of the selected columns within each group;

  • mean / meanOf / meanFor — calculate the mean (average) of all values on the selected columns / by a row expression / for each of the selected columns within each group;

  • std / stdOf / stdFor — calculate the standard deviation of all values on the selected columns / by a row expression / for each of the selected columns within each group;

  • median / medianOf / medianFor — calculate the median of all values on the selected columns / by a row expression / for each of the selected columns within each group;

  • percentile / percentileOf / percentileFor — calculate a specified percentile of all values on the selected columns / by a row expression / for each of the selected columns within each group.

For more information: See "groupBy statistics" on the documentation website.