Skip to content

dataFrameFromColumns

dataFrameFromColumns(fields, columns, meta?): DataFrame

Defined in: packages/model-dataset/src/frame/data-frame.ts:213

Builds a frame from columns already in hand — the counterpart of dataFrameFromRows, for a producer that computes a whole series at a time rather than a record at a time.

O(f) in the field count: columns are stored by reference, never copied or repacked, so a caller that already built a Float64Array keeps it. That is also the reason to prefer this over dataFrameFromRows for sampled data — the row-major path boxes every value and then transposes it.

readonly FieldDescriptor[]

One descriptor per column, in column order.

readonly Column[]

Parallel to fields, all of the same length.

FrameMeta

DataFrame

const frame = dataFrameFromColumns(
[
{ name: "x", kind: "quantitative" },
{ name: "y", kind: "quantitative" },
],
[Float64Array.from([0, 1, 2]), Float64Array.from([0, 1, 4])],
);
frame.rowCount; // 3
```;
## Throws
When the column count differs from the
field count, or the columns are not all the same length.