stats/grouped_stats_utils library
Per-key descriptive statistics over an iterable — roadmap #571.
Where aggregateByKeys (collections) takes a custom reducer, this computes
the common numeric bundle — count, sum, min, max, mean — for every group in
a single pass. The frequent "totals and averages per category" report
without writing the reducer each time.
Classes
- NumericStats
- Descriptive statistics for one group of numeric values.
Functions
-
groupedStats<
T, K> (Iterable< T> items, {required K keyOf(T), required num valueOf(T)}) → Map<K, NumericStats> -
Groups
itemsbykeyOfand computes a NumericStats bundle overvalueOffor each group, in a single pass. A key appears only if at least one item maps to it, so every returned NumericStats hascount ≥ 1(no divide-by-zero inmean). Insertion order of first-seen keys is preserved.