Pandas Cov
Covariance, not correlation — the matrix that keeps the scale
- dataframe
- DATAFRAME
Pandas Cov computes the covariance matrix of a DataFrame: a square table showing how every pair of numeric columns co-vary. If Pandas Corr is the friendly, normalized version everyone plots, covariance is the version that keeps the raw scale - and that difference is the whole reason both exist.
How it works
It's a wrapper over pandas' dataframe.cov(). For each pair of columns it computes how they move together: a positive value means they tend to rise and fall together, negative means they move opposite, and zero means no linear relationship. Crucially, the values are not normalized to -1..+1 - they carry the units and magnitude of the data. Two columns measured in thousands will show huge covariance numbers even if they're only loosely related.
That's the mental model: correlation tells you direction and strength; covariance tells you direction and scale. If you've already read the Corr article, think of this as the same idea with the units left in. The diagonal holds each column's variance - how much it spreads on its own - which is itself useful.
Inputs and outputs
dataframe- the frame to analyze (DATAFRAME)- Output: a
DATAFRAMEcontaining the symmetric covariance matrix
When you'd reach for it
When scale genuinely matters. Portfolio-style problems ("this pair moves together by this many units"), variance budgets, or any analysis where you want to know not just that two columns correlate but how much they co-move in real units. The diagonal also gives you per-column variance in one shot. And since the output is a plain DataFrame, it composes like everything else here - drop it into Seaborn Heatmap for a colored covariance plot, or slice out a specific covariance with Pandas At Float.
Installing it
Ships with ComfyUI-Data-Analysis (Hide Inada / HowToSD.com). Manager: search Data Analysis → install → restart. Or:
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 comes via requirements.txt (Manager installs it).
Gotchas
Non-numeric columns are ignored, same as correlation - missing columns in the output means they weren't numeric, so run Pandas As Float if unsure. Covariance is also sensitive to scale by design, so comparing covariances across differently-scaled column pairs is apples-to-oranges; if you just want "which pairs relate," use Pandas Corr. And with few rows or missing values, covariance gets noisy fast - the overlapping-pairs handling pandas uses can make small datasets look more meaningful than they are.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| dataframe | DATAFRAME | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| DATAFRAME | DATAFRAME | — |