Pandas Crosstab
Count how often two categories line up, in one node
- dataframe
- DATAFRAME
Pandas Crosstab is the node for the classic data question: "how many rows fall into each combination of these two categories?" It builds a contingency table - rows for one categorical column, columns for another, cell counts where they intersect. If you've ever wanted to know how many hits each player had in each year, or how many samples fall into each label × split combo, this is the node. It's the kind of summary that takes three lines of pandas and is deeply annoying to eyeball by hand.
The mechanism is pd.crosstab(index=..., columns=...), wrapped in this pack's wire types. It takes a DATAFRAME and two text fields that name the columns you want to cross:
index- comma-separated column labels to use as rows.column_names- comma-separated column labels to use as columns.
Both accept more than one column, which is where crosstab gets genuinely powerful: you can cross two row categories against two column categories and get a richer grid. If you pass a single label, the node feeds that column straight in; multiple labels become lists, and pandas builds the multi-level table.
The gotcha that will actually bite you
Column labels are validated against the DataFrame, and a typo is not forgiven - the node raises ValueError(f"Column '{c}' not found in the DataFrame.") and your run dies with a traceback. That's a real footgun because it's not a nice dropdown; you're typing names into a text field by hand, and "hits " with a trailing space will fail. The good news: the parser strips whitespace and will even convert a numeric-looking label to an integer if that's how the column is named, so a sensible typo-free entry usually works.
Only feed it categorical data. If you cross two continuous numeric columns you'll get a table where nearly every cell is a lonely 1 - technically correct, practically useless. That's the overhyped-adjacent failure mode of crosstab; keep it for categories.
Output and workflow
Output is a DATAFRAME - the contingency table itself. It wires straight into Pandas Show DataFrame to eyeball, or into a seaborn heatmap node (this pack wraps those too) to make the pattern visible. That's the typical arc: load data → crosstab → heatmap. The pack's whole pitch - visual data analysis in the node graph - is basically this node in a nutshell.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
mv ComfyUI-Data-Analysis data-analysis
pip install -r requirements.txt
or ComfyUI Manager → search "Data analysis" → install → restart. No GPU, no models - pandas is the whole engine.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| dataframe | DATAFRAME | — | |
| index | STRING | — | |
| column_names | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| DATAFRAME | DATAFRAME | — |