ComfyUI Node

Pandas Var

Per-column variance, because std alone doesn't tell the story

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Pandas Var
  • dataframe
  • PDSERIES

Pandas Var computes the variance of each column in a DataFrame and returns it as a Series. It's the quieter sibling of Pandas Std - same shape, same inputs, one number per column - and it answers a slightly different question: not "how far are values typically spread" but "how much does this column vary, squared."

Where variance earns its place: it's the statistic that pops up in feature-selection and modeling sanity checks. A column with near-zero variance is useless as a predictor (it never changes), and a column whose variance dwarfs the others will dominate any unnormalized distance-based math downstream. Run Pandas Var, look at the spread of the numbers, and you'll spot both pathologies fast. In a ComfyUI-Data-Analysis workflow you'd pair it with Pandas Std and Pandas Summary to get the full picture of a column's distribution before you decide whether to normalize it.

How it works

It's dataframe.var(). Pandas defaults to ddof=1 - the sample variance - which matches what Pandas Summary's output implies and what the pack's std node computes, so the numbers are consistent across the family. It runs down the columns (one result per column), skips NaN, and returns a Series indexed by column name. Non-numeric columns come back as NaN.

Inputs and outputs

  • dataframe (DATAFRAME) - the frame to measure.

Output: a single PDSERIES, one variance per column. Wire it into Pandas Show Series to read it, Pandas Series To Dataframe to table-ify it, or Pandas Sub Series if you're building a normalization pipeline.

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

  • Huge numbers. Variance is standard deviation squared, so it's always in different units than your data. That's not a bug - compare variances relative to each other, or take Pandas Std if you want interpretable units.
  • Column came back NaN. Non-numeric column. Convert or drop it upstream.
  • "Wait, ddof?" It's sample variance (ddof=1), same convention as the rest of the pack. No toggle for population variance here - if you need that, you're outside this node's scope.
CategoryData Analysis

Inputs (1)

NameTypeDefaultDescription
dataframeDATAFRAME

Outputs (1)

NameTypeDescription
PDSERIESPDSERIES