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.
Parameters
Section titled “Parameters”fields
Section titled “fields”readonly FieldDescriptor[]
One descriptor per column, in column order.
columns
Section titled “columns”readonly Column[]
Parallel to fields, all of the same length.
Returns
Section titled “Returns”Example
Section titled “Example” 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.