Pandas Sub Series
Subtract a Series from every row of a DataFrame
- a_dataframe
- b_series
- DATAFRAME
The middle child of the pack's subtraction family. Pandas Sub Series subtracts a Series from a DataFrame - and unlike the scalar variants, that means it can subtract a different value per column. A Series holds one value per column (think "the mean of each column"), so this node is the natural way to de-mean an entire frame in one shot: compute column means with Pandas Mean, feed them in, and every column comes out centered on zero.
That's the classic use, and it's a good one. Any time you have a per-column offset - means, medians, baselines, reference values - this node applies it across the whole table. Where Pandas Sub aligns two full frames (label-by-label), and the scalar nodes apply one constant everywhere, this one sits in between: one number per column, applied row-wise.
How it works
a_dataframe.sub(b_series). As with the DataFrame variant, pandas aligns by label before subtracting - the Series is matched against the DataFrame's columns. Two practical consequences: the Series needs a value for each column you want shifted (missing labels produce NaN), and extra Series entries are ignored. The subtraction runs down the index, so the same per-column offset is removed from every row.
Inputs and outputs
a_dataframe(DATAFRAME) - the frame to shift.b_series(PDSERIES) - one value per column, usually produced byPandas Mean,Pandas Median, orPandas Sumin the same pack.
Output: a single DATAFRAME, each column reduced by its matching Series value.
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
- Columns came back NaN. The Series didn't have a matching entry for them - its index labels didn't line up with the DataFrame's columns. Check what the Series holds with
Pandas Show Seriesand make sure it was computed from the same frame. - I meant to subtract a whole frame. If your second input is a full DataFrame with multiple rows of offsets, you want
Pandas Sub, not this node. This one expects a single Series. - Column order doesn't matter - alignment is by label, not position, so reordering columns won't change the math. That's a feature, but it means a typo in a label silently produces NaN instead of an error.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| a_dataframe | DATAFRAME | — | |
| b_series | PDSERIES | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| DATAFRAME | DATAFRAME | — |