Pandas Value Counts
How often does each value show up?
- dataframe
- DATAFRAME
Pandas Value Counts builds a frequency table from one or more columns - for each distinct value, how many rows have it. It's the categorical workhorse of the pack: the answer to "which team appears most in this dataset?" or "how many rows per category?" and the natural preamble to a bar chart of counts.
It's aimed squarely at categorical data, and it's a good node because it cleans up after pandas' awkward value_counts() output. When you count a single column, pandas hands you a Series with the categories as the index and the counts as values - awkward for a table-oriented graph. This node reshapes it properly: a Category column with the values, a Count column with the frequencies, sorted by count descending. It's one of the few nodes in the pack whose implementation does real cleanup work rather than a one-line passthrough, and the source comments walk through exactly why the reshape is needed.
How it works
Give it one column name and it returns a tidy two-column table: original column name + Count. Give it several comma-separated columns and it counts the combinations - each unique row of values across those columns gets a frequency, again with a Count column. Single-column results restore the original column label; multi-column results follow pandas' convention of naming the count column Count. Either way, NaN handling follows value_counts()' default (missing values are dropped from the count).
Inputs and outputs
dataframe(DATAFRAME) - the frame to count over.column_names(STRING, default empty) - comma-separated column names, e.g.teamorleague,team.
Output: a single DATAFRAME - the frequency table. Wire it into Pandas Show DataFrame to read it, or a bar-plot node to visualize the distribution.
Installing this pack
This node ships in ComfyUI-Data-Analysis by Hide Inada (HowToSD). CPU-only, no GPU, no model downloads - but the pack needs its Python stack, which stock ComfyUI lacks: pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl, lxml.
ComfyUI Manager: Manager → Custom Node Manager → search "Data analysis" → install ComfyUI-Data-Analysis → restart ComfyUI and refresh the browser. Manager installs the deps.
Git clone:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
mv ComfyUI-Data-Analysis data-analysis # example workflows depend on this folder name
pip install -r data-analysis/requirements.txt
Restart ComfyUI after installing.
Troubleshooting
- "Column not found" error.
column_namesmust match real columns exactly, including case. Check the labels withPandas Columnsfirst. - Where did the categories go? If you only see a
Countcolumn, check you didn't pass multiple columns when you meant one - multi-column output's structure differs from the single-column tidy table. - Counts are sorted descending. That's
value_counts()' default behavior; there's no ascending toggle on this node. If you need a different order, sort the result withPandas Sort.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| dataframe | DATAFRAME | — | |
| column_names | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| DATAFRAME | DATAFRAME | — |