ddn.df.frame

The DataFrame layer of ddn.df: an ordered collection of named Series columns of equal height (D11).

A DataFrame is a value type; copying copies the column array, not the data. Construction validates equal heights and unique names; lookups resolve by name (df["x"]) or position (df[0], df[1u]); logical equality compares schema and values regardless of per-column chunking.

Types 1

structDataFrame

A table: named, typed Series columns of equal height. DataFrame.init is the empty frame (no columns, height 0).

Fields
private ColumnBatch _batch
Methods
private Series[] _columns() @property const @trusted pure nothrowThe frame's columns (the carrier's storage, shared - never a copy).
size_t height() const @safe pure nothrowReturns: the number of rows (0 for the empty frame).
size_t width() const @safe pure nothrowReturns: the number of columns.
size_t[2] shape() const @safe pure nothrowReturns: `(height, width)`.
string[] columns() @safe pure nothrowReturns: the column names, in order.
Schema schema() @safe pureReturns: the schema of the frame.
DataType[] dtypes() @safe pure nothrowReturns: the column dtypes, in order.
bool isEmpty() const @safe pure nothrowReturns: `true` when the frame has no rows or no columns.
Series column(string name) @safe pureParams: name = the column name
Series opIndex(string name) @safe pureParams: name = the column name
Series opIndex(size_t i) @safe pureParams: i = the column position
bool hasColumn(string name) const @safe pure nothrowParams: name = the column name
Nullable!size_t columnIndex(string name) const @safe pureParams: name = the column name
Series[] columnsArray() @safe pure nothrowReturns: the columns, in order (the array is a copy).
DataFrame select(string[] names...) @safe pureProjects the named columns, in the given order.
DataFrame drop(string[] names...) @safe pureDrops the named columns.
DataFrame rename(string[] from, string[] to) @safe pureRenames columns: `rename(["a", "b"], ["x", "y"])`.
DataFrame join(DataFrame other, string on, JoinKind kind = JoinKind.INNER, string suffix = "_right")Joins another frame on equal-dtype key columns (INNER default, or LEFT): rows in left-frame order, right-frame order within one left row; null keys never match; the key coalesces; right-side collis...
DataFrame join(DataFrame other, string[] leftOn, string[] rightOn, JoinKind kind = JoinKind.INNER, string suffix = "_right")Ditto, the multi-column join (ADR-2026-10-30-03): a row matches only when every key pair holds; any null component never matches. OUTER coalesces every paired key column.
DataFrame join(DataFrame other, string[] on, JoinKind kind = JoinKind.INNER, string suffix = "_right")Ditto, the same key names on both sides.
DataFrame crossJoin(DataFrame other, string suffix = "_right")The cross join (ADR-2026-10-30-03): the left-major nested loop - every left row in order, all right rows in right order within it - with the row count overflow-checked before any allocation. Right-...
DataFrame joinAsof(DataFrame other, string leftOn, string rightOn, AsofDirection direction = AsofDirection.BACKWARD, long tolerance = long.max)The sorted asof join (ADR-2026-10-30-03): for each left row, at most one right row - BACKWARD the last with `rightKey <= leftKey`, FORWARD the first with `>=`, NEAREST the smaller distance (exact t...
DataFrame joinAsof(DataFrame other, string on, AsofDirection direction = AsofDirection.BACKWARD, long tolerance = long.max)Ditto, the same key name on both sides.
DataFrame join(DataFrame other, string leftOn, string rightOn, JoinKind kind = JoinKind.INNER, string suffix = "_right")Ditto, with different key column names on the two sides.
GroupBy groupBy(string[] keys...)Groups the frame by its key columns: first-appearance group order, null keys forming their own group.
DataFrame describe()Deduplicates the frame's rows (ADR-2026-10-23-08): the first occurrence of each distinct key tuple is kept, in first-appearance order, under the grouping's total multi-column equality (nulls equal,...
private Nullable!double colMaxAsDouble(Series col)
auto deferred() @safe pure nothrowWraps the frame in a LazyFrame for deferred execution: build with .filter/.select/.withColumn/.sort/.limit, collect with .collect(). Nothing runs until collect. The result equals the equivalent eag...
DataFrame unique(string[] subset = null)
DataFrame pivot(string[] index, string on, string[] values, PivotAgg agg = PivotAgg.NONE)Pivots the frame wide: the distinct values of `on` become columns, the distinct `index` tuples become rows, and the cells hold the `values` aggregated per (index tuple, on value) - first-appearance...
DataFrame unpivot(string[] valueColumns, string[] indexColumns = [], string variableName = "variable", string valueName = "value")Unpivots the frame long: the `valueColumns` stack into `variableName`/`valueName` pairs (value-column outer, input row inner), the `indexColumns` repeat per stacked column, and every other column d...
DataFrame sort(string by, bool descending = false, bool nullsLast = false)Sorts the frame by one key column (stable; nulls first by default).
DataFrame sort(string[] by, bool[] descending, bool nullsLast = false)Sorts the frame by several key columns: one stable pass per key, last key first, so earlier keys break the ties of later ones.
DataFrame slice(size_t start, size_t len)Row slice: every column is sliced identically, sharing its buffers.
DataFrame head(size_t n = 10)The first `n` rows.
DataFrame tail(size_t n = 10)The last `n` rows.
DataFrame filter(Series mask)Keeps the rows whose mask entry is `true`; a null mask entry counts as `false`. Every column is filtered identically.
DataFrame dropNulls(string[] subset = null, NullHow how = NullHow.ANY)Drops rows by a null criterion over the selected columns. `how = ANY` (default) drops a row when any selected column is null; `how = ALL` drops a row only when every selected column is null. `subse...
DataFrame take(const(size_t)[] indices)Gathers the rows at `indices`, in order.
DataFrame withColumn(Series col) @safe pureAdds or replaces one column by name: an existing column of that name is replaced in place, otherwise the column is appended (with a height check).
DataFrame withColumns(Series[] cols) @safe pureAdds or replaces several columns in one pass. The semantics are sequential `withColumn` over the array: an existing name is replaced at its own position, a new name is appended in batch order, and ...
DataFrame insertColumn(size_t index, Series col) @safe pureAdds or replaces one column at a position. An existing name is replaced at its own position - the `index` applies to new names only. A new name is inserted at `index`, where `0 ..= width()` is vali...
DataFrame hstack(Series[] cols) @safe pureAppends columns to the right.
DataFrame vstack(DataFrame other)Stacks another frame below: the schemas must match by name and dtype (same order); the result references both frames' chunk arrays, so it is O(1) per column.
DataFrame rechunk()Returns: the frame with every column rechunked to one chunk.
string toString()Renders the frame Polars-style:
private string truncate(string s) static @safe pure
private size_t maxReduce(size_t a, size_t b) static @safe pure nothrow
private bool isNumericKind(Kind k) static @safe pure nothrow
bool equals(DataFrame other, bool nullEqual = true)Logical equality: same schema and logically equal columns, independent of per-column chunking (delegates to `Series.equals`).
bool opEquals(DataFrame other)Logical `opEquals`: `equals` with the default `nullEqual`.
Constructors
this(Series[] columns)Constructs from columns, validating equal heights and unique names.

Functions 2

private fnvoid appendOptInto(T)(ref PrimitiveBuilder!double b, Nullable!T v)
fnsize_t[] multiKeyArgSort(DataFrame frame, string[] by, bool[] descending, bool nullsLast = false)Sorts the rows of a frame by its key columns: one stable pass per key, last key first, so earlier keys become the tie-break of later ones. Every pass applies the null placement. The frame adapter r...