- dataframe
- DATAFRAME
Pivot is the node you reach for when your data is in the wrong shape. You've got rows that should be columns - like one row per player per year, when what you actually want is years across the top and players down the side, with the stat in the cells. That reshape is exactly what Pandas Pivot does, and it's the most "wow, this is real spreadsheet software" node in the pack. The author's own tutorial even opens with an MLB hits question, which is textbook pivot material.
It's part of the HowToSD/ComfyUI-Data-Analysis extension, which wraps pandas into visual nodes so you can run tabular analysis without leaving the ComfyUI canvas. Pivot is listed under its Transformation category, and it's one of the genuinely useful ones if you're doing any serious data exploration.
How it works
The node calls pandas' DataFrame.pivot(index=..., columns=..., values=...). The mental model: you pick one column whose unique values become the new column headers, one column whose values become the new row labels, and one column whose values fill the cells. Think of it as the opposite of "melting" - you're folding rows up into a wider table.
A couple of mechanical notes. Each of the three inputs is a plain string field, but they're comma-separated, so you can pivot on multiple columns at once and the node splits them for you (single names work fine too). And this is pivot, not pivot_table: if your index+columns combination has duplicate rows, pandas raises a ValueError instead of quietly averaging. That's the number-one way this node bites people.
The inputs
dataframe- your source table.index- the column (or columns) whose values become the new row labels.columns- the column whose values become the new column headers.values- the column that supplies the numbers in the cells.
Output is a single reshaped DATAFRAME. It plugs straight into everything else in the pack - plot it, save it, feed it onward.
Install and context
Same as every node in this pack: ComfyUI Manager (search Data analysis) or clone manually and rename the folder to data-analysis:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
mv ComfyUI-Data-Analysis data-analysis # examples expect this name
pip install -r requirements.txt
Restart, reload, done. It pulls pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl and lxml. No models, no GPU needed - this is a CPU data-analysis pack through and through.
The trap
Duplicates, as mentioned. pivot demands a unique index+columns pair per row. If your data has repeats, you have two options: aggregate first with a Group By node (sum/mean whatever you need) so the pairs become unique, or accept that pivot isn't the tool for aggregation and use a groupby-based reshape instead. Every person I've seen swear at this node was really swearing at duplicate data. Also, note the field names - index and columns are the actual column names from your table, not the words "index" and "columns", which trips up the first run.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| dataframe | DATAFRAME | — | |
| index | STRING | — | |
| columns | STRING | — | |
| values | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| DATAFRAME | DATAFRAME | — |