ComfyUI Node

Pandas Corr

The whole correlation matrix, in three flavors

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

"Which columns move together?" is the first question anyone asks about a new dataset, and Pandas Corr is the node that answers it. It takes a DataFrame and returns the full pairwise correlation matrix - a square table where every cell says how strongly two columns track each other, from -1 (perfect inverse) to +1 (perfect match). This is one of the pack's headline summary-statistics nodes, and it's the one you'll actually show off.

How it works

It's a thin wrapper over pandas' dataframe.corr(method), with the method selectable:

  • pearson - the default, linear correlation. Best for relationships that move in straight lines.
  • spearman - rank-based; catches monotonic relationships that aren't linear (e.g. exponential growth). More robust to outliers.
  • kendall - also rank-based, computed from concordant/discordant pairs; slower but sturdier on small, heavily tied datasets.

The output is a symmetric matrix: cell [i, j] is the correlation between column i and column j, with 1.0 down the diagonal. pandas drops non-numeric columns automatically and handles missing values pairwise, so a few NaNs won't kill it.

Inputs and outputs

  • dataframe - the frame to analyze (DATAFRAME)
  • method - enum: pearson, kendall, or spearman
  • Output: a DATAFRAME containing the correlation matrix

Why this node earns its place

Because a correlation matrix is a table, it plugs right into the rest of the pack. The classic move: feed it into the Seaborn Heatmap node (also in this pack) and you get the standard colored correlation plot with zero fuss. That's the workflow that makes data analysis in ComfyUI feel legitimate - load CSV → Corr → Heatmap, and you've got a real analysis artifact. Beyond the visual, the matrix itself is data: you can slice it with Select Columns or read specific cells with Pandas At Float to extract "the correlation between A and B" as a number for downstream logic.

Installing it

Part of ComfyUI-Data-Analysis (author Hide Inada / HowToSD.com). Manager: search Data Analysis → install → restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
mv ComfyUI-Data-Analysis data-analysis
pip install -r data-analysis/requirements.txt

No GPU needed; pandas, seaborn and matplotlib come via requirements.txt.

Gotchas

Correlation is only meaningful on numeric columns - the node silently ignores text ones, so if a column you expected is missing from the matrix, that's why. Run Pandas As Float first if you're not sure a column parsed numerically. And a small dataset can produce misleading correlations; with a handful of rows you'll see near-perfect numbers everywhere, which says more about sample size than about your data. Also note pandas pairs off NaNs, so two columns with missing values in different rows get computed from just the overlapping rows - read the matrix with that in mind.

CategoryData Analysis

Inputs (2)

NameTypeDefaultDescription
dataframeDATAFRAME
methodCOMBO3 options: pearson, kendall, spearman

Outputs (1)

NameTypeDescription
DATAFRAMEDATAFRAME