ComfyUI Node

Pandas Mode

The most common value in every column — all of them

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Pandas Mode
  • dataframe
  • DATAFRAME

The mode is the value that shows up most often - the most common price, the most frequent category, the typical outcome. Pandas Mode computes it for every column in a DataFrame. What makes this node different from its summary-statistics siblings is the output shape: instead of a PDSERIES, it returns a DATAFRAME, because a column can be tied for most common, and pandas is honest enough to hand you every winner.

It's part of ComfyUI-Data-Analysis by Hide Inada (HowToSD), the pack that wraps pandas, Seaborn, and Matplotlib into ComfyUI nodes for doing real data analysis in the same canvas where you generate images. This node is a straight passthrough of dataframe.mode().

How it works

The node runs dataframe.mode(). For each column it finds the value(s) with the highest count and returns them - one row when there's a single winner, multiple rows when there's a tie. That's why the output is a DataFrame rather than a Series: it needs room for more than one answer per column. NaN values are ignored in the counting.

The practical consequence is in the wiring. Because the result can be taller than one row, you can't just treat it like the Max/Mean outputs. If you only care about the single most common value, take the first row - or feed the output into Pandas Head to trim it. When a column is all unique values, the mode is simply the whole column, so don't be alarmed if the output is longer than you expected.

The inputs that matter

One input: dataframe. That's it - no parameters to tune, the node just asks pandas "what's most common in each column?"

How to install it

Standard for this pack:

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 → reload. The usual heavy dependencies (pandas, matplotlib, seaborn, scipy, scikit-learn) arrive with the pack; nothing GPU-related, no model files.

Common issues

  • Output is longer than one row - that's a tie (or an all-unique column), not an error. Take the first row if you want the single most common value.
  • A column returns everything - all values in that column appear the same number of times (usually one each). That's pandas telling you the column is basically a unique identifier, which is useful information.
  • It's the summary node people misjudge - because of the multi-row output, Pandas Mode trips people up more than Max or Mean. The trick is just remembering it can't always fit in one row.

The mode is the most-overlooked of the three Ms - mean, median, mode - and this node is why you don't have to ignore it. Just respect the DataFrame output.

CategoryData Analysis

Inputs (1)

NameTypeDefaultDescription
dataframeDATAFRAME

Outputs (1)

NameTypeDescription
DATAFRAMEDATAFRAME