Ciaren

Pivot a Table

Pivot a Table

The Pivot node spreads the unique values of one column into new columns, filling each cell by aggregating a values column. It's the classic "long → wide" reshape.

You'll use: File Input → Pivot → File Output.

File Input
sales_long.csv
input
Pivot
index region · columns month · values amount
transform
File Output
sales_wide.csv
output

Steps

  1. File Input — select your long-format dataset.
  2. Pivot — set:
    • index: ["region"] — the row key(s)
    • columns: "month" — the column whose values become new columns
    • values: "amount" — the column to aggregate into the cells
    • aggfunc: "sum" — how to combine collisions (default sum)
  3. File Output — write the wide table.

Before / after

Before
regionmonthamount
NorthJan100
NorthFeb120
SouthJan80
3 rows · 3 cols
Pivot (index=region, columns=month, values=amount, aggfunc=sum)
After
regionJanFeb
North100120
South80null
2 rows · 3 cols

South has no Feb row in the source data, so its Feb cell comes out null (pivot_table doesn't fill missing index/column combinations by default) — add a Fill Nulls node after Pivot if you want those cells to read 0 instead.

Tips

  • New column names come from the values found in columns at run time.
  • Need the inverse (wide → long)? Use Unpivot.

See also