Nodes/ComfyUI-Data-Analysis/Pandas Add Series
ComfyUI Node

Pandas Add Series

Shift each column by its own amount, using a Series

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Pandas Add Series
  • a_dataframe
  • b_series
  • DATAFRAME

The two scalar-add nodes nudge the whole table by one number. Pandas Add Series is for when each column gets a different amount. You feed it a DataFrame plus a pandas Series, and it adds the series into the frame - per column, aligned by label. It's the difference between "add 5 to everything" and "add 1 to column a, 2 to column b, 3 to column c."

How it works

The node calls a_dataframe.add(b_series), and the alignment is the whole game. With pandas' default behavior, the Series index aligns with the DataFrame's columns: every value in column a gets the series entry for a added to it, and so on. The Series acts like a per-column offset vector.

The catch is alignment again. If a series index label doesn't match a column label, pandas doesn't complain - it fills that column with NaN. So the classic bug is building a Series whose index names don't exactly match your columns (or are in a different order, which pandas handles by label so order doesn't matter - only names do).

Inputs and outputs

  • a_dataframe - the frame you're offsetting (DATAFRAME)
  • b_series - the offsets, a PDSERIES input
  • Output: a DATAFRAME with each column shifted

Where do you get a Series in this pack? Two handy routes: Pandas Select Column As Series pulls one column out of an existing frame, and Pandas Create Series From List builds one from a list (feed it a list from the pack's CDA JSON Create node). The latter is the one to reach for when you want to type your offsets by hand.

A genuinely useful trick

Because the Series aligns by column label, you can compute offsets inside the graph - e.g. take a column of baseline values with Select Column As Series and add them across the whole frame. That's the pattern for "center every row relative to its baseline," and it's hard to do in stock ComfyUI without this pack at all.

Installing it

It ships with ComfyUI-Data-Analysis. 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; requirements pull pandas, matplotlib, seaborn and friends.

Where people trip

The index/column mismatch producing a wall of NaN is the number-one footgun - if your output suddenly looks empty, check that the Series index matches the frame's column names exactly. And remember the Series must contain numbers; a string Series will raise when pandas tries to add it. Convert with the pack's Pandas As Float if you're unsure what got into it.

CategoryData Analysis

Inputs (2)

NameTypeDefaultDescription
a_dataframeDATAFRAME
b_seriesPDSERIES

Outputs (1)

NameTypeDescription
DATAFRAMEDATAFRAME