pivot-wider
Spread a name column and a value column into one column per name (long to wide).
NoteExperimental
This function is experimental; its interface may change without notice.
Since 0.6.0.
names-from holds the new column names, values-from their cell values; every other column identifies the output row. Rows sharing the identifier columns collapse into one, with a column per distinct names-from value (stringified, since dict keys are strings) in first-appearance order. Absent name/identifier combinations are filled with none; a repeated combination (the same names-from value twice within one identifier group) is an ambiguous spread and fails.
Usage
pivot-wider(
data,
names-from: none,
values-from: none,
)Parameters
| Parameter | Default | Description |
|---|---|---|
data |
Row-store (array of dicts) or column-store (dict of arrays). | |
names-from |
none |
Column whose values become the new column names. |
values-from |
none |
Column whose values fill the new columns. |
Returns
A wide row-store array.
Examples
Spread a key column into one column per key.
#let wide = pivot-wider(long, names-from: "metric", values-from: "mpg")