ddn.df.groupby
The grouping layer of ddn.df: DataFrame.groupBy returning a GroupBy with groups, len and agg (T27; D12; ADR-2026-10-18-05, ADR-2026-10-18-15).
The GroupTable maps (row hash, representative row) to a group id in first-appearance order — free with open addressing, where Polars needs maintain_order=True. The aggregation kernels of ddn.df.compute (one-slot ArrayData producers, ADR-2026-10-18-14) produce the per-group output columns directly, one slot per group.
Implements ADR-2026-10-18-20 (amending ADR-2026-10-18-14): the grouped aggregations walk the group's row list through cached typed views - same one-slot results, same semantics - instead of gathering per group, and the group rows live in one flat index array.
Copyright
Types 4
The aggregation kinds GroupBy.agg accepts.
One aggregation specification for GroupBy.agg.
AggKind kindThe aggregation kind.string columnThe source column name.string outputNameThe output column name (defaults to the source name).double paramThe statistical parameter: `q` for QUANTILE, `ddof` for STD/VARIANCE (ignored by the parameterless kinds; ADR-2026-10-28-01).private size_t[] _hashesprivate size_t[] _rowsprivate size_t _countprivate const(ArrayData)[][] _keyChunksprivate size_t[][] _keyStartsprivate const(ColumnEq)[] _keyEqsprivate const(ArrayData)[] _fastColprivate size_t[] _fastStartsprivate Kind _fastKindprivate ulong[] _fastWordsThe grouped view of a frame: the key columns plus per-group row lists.
private DataFrame _frameprivate string[] _keysprivate size_t[][] _groupRowsprivate size_t[] _ordersize_t[] representativeRows() @safe pure nothrowThe first-appearance representative row of every distinct key tuple, in discovery order - the frame-level `unique` keep-first semantics (ADR-2026-10-23-08). Key equality is the grouping's total mul...size_t count()Returns: the number of groups.size_t[][] groups()The per-group row index lists, in first-appearance order.Functions 29
AggSpec product(string column, string as = "")Factory for the product of `column` (the sum's promotion; identity 1; integers wrap; nulls skipped - ADR-2026-10-28-01).AggSpec median(string column, string as = "")Factory for the median of `column` (the 0.5 quantile; FLOAT64).AggSpec quantile(string column, double q, string as = "")Factory for the `q` quantile of `column` (linear interpolation on the total order; FLOAT64; `q` must lie in [0, 1]).AggSpec std(string column, size_t ddof = 1, string as = "")Factory for the sample standard deviation of `column` (two-pass; FLOAT64; `ddof` >= the group's valid count reads null).AggSpec variance(string column, size_t ddof = 1, string as = "")Factory for the sample variance of `column` (two-pass; FLOAT64; `ddof` >= the group's valid count reads null).size_t chunkIndexOf(const size_t[] starts, size_t row) @safe pure nothrowThe binary search of the chunk holding a global row over its start table (logarithmic where `locateGlobal` walks the chunk list from the front every call).Series aggCollect(string outName, Series col,
size_t[][] groupRows)Aggregates one column over every group's row list, producing the single-chunk output Series of one slot per group.Series aggStat(AggKind kind, double param, string outName,
Series col, size_t[][] groupRows)Series aggColumnBatched(string agg)(string outName,
Series col, size_t[][] groupRows)The batched sibling of `aggColumn` (ADR-2026-10-24-20): the same slot arithmetic - one `aggInto` per group, the very statements the one-slot kernels run - appended into ONE builder, so the output i...void aggInto(string agg, Kind K, Build)(ref GatherCursor!K cursor,
const size_t[] rows, ref Build b)The aggregation arithmetic itself: appends exactly one slot (value or null) into `b` - the same statements the one-slot kernel has always executed, moved verbatim so the one-slot and batched paths ...DataType aggDtypeOf(AggKind agg, DataType d) @safe pure nothrowThe promoted sum dtype of one kind, mirroring the one-slot sum kernel of `ddn.df.compute`: narrow integers widen to INT64, BOOLEAN sums into UINT32, everything else keeps its own kind.Series overAgg(DataFrame df, string column, string[] keys,
string agg) @trustedComputes a partitioned aggregation and scatters each partition's result back to every input row of that partition (the `over` semantics of ADR-2026-10-24-17: the output has the input's length and r...Series overAgg(DataFrame df, string column, string[] keys, string agg,
double param) @trustedDitto, with the statistical parameter: `q` for "quantile" (default 0.5 - "median" is its alias), `ddof` for "std" and "variance" (default 1; ADR-2026-10-28-01).DataFrame groupByDynamic(DataFrame df, string timeColumn, long every,
long period, long offset = 0, Closed closed = Closed.LEFT,
size_t minPeriods = 1, AggSpec[] specs...) @trustedThe dynamic time buckets (ADR-2026-10-30-03): windows anchored at `epoch + offset`, advancing by `every`, each row joining every bucket whose period contains it - `Closed.LEFT` the `[start, start +...Templates 4
One aggregation over one group's row list, at the column's own kind: the one-slot semantics of the ddn.df.compute kernels (the sum promotion, the double mean accumulator with one rounding, the total order on floats, null-skip and null-propagation) applied through one cached view per chunk - no gather materialised.
Parameters
agg | the aggregation kernel name |
K | the aggregated kind |
chunks | the aggregated column's chunks |
chunkStarts | the global start index of every chunk |
rows | the group's rows, in original order |