ComfyUI Node

Pandas Cumsum

The running total, the workhorse of the cumulative family

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

Pandas Cumsum is the one you'll actually use. Running totals are everywhere - cumulative hits by year, cumulative spend, cumulative token counts, "how much have I generated so far" metrics. Every output cell holds the sum of everything up to and including that cell, which turns a column of per-period numbers into a column of running totals. If you use exactly one node from this pack's cumulative quartet, it should be this one.

Mechanically it's a one-line pandas call:

df_out = dataframe.cumsum(axis=0 if axis == "index" else 1)

with the pack-standard axis enum: index (down the rows, pandas axis=0) or columns (across, axis=1). The naming trap applies - "index" means vertical, because the index runs down the page - and getting it backwards gives you running totals across each row instead of down each column. Pick index for the normal "running total down a column" case and you're set.

Inputs and outputs: dataframe (DATAFRAME) plus the axis enum, output a same-shaped DATAFRAME. Nothing else to configure.

What to watch

Two behaviors are worth internalizing. First, NaNs: like every cumulative node in the pack, a missing value blanks the running total until data resumes - the sum is NaN while any prior cell is NaN. Drop or fill missing values first with Pandas Drop NA / Fill NA if you need a clean curve. Second, cumulative sums are the "gentle" cousin of Cumprod: they grow linearly, never explode, and are almost always safe to feed arbitrary data. When in doubt between Cumsum and Cumprod, pick Cumsum - it's the one that does what you meant.

The classic workflow: load or create a per-period table (hits per year, cost per day), run Pandas Cumsum down the column, then feed the result into a line plot node from the pack's seaborn/matplotlib side. "Running total over time" is one of the most-viewed line charts in data analysis, and this node is the entire pipeline for it in the graph.

Install

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

or ComfyUI Manager → search "Data analysis" → install → restart. No GPU, no models. And the usual README reminder: keep the folder named data-analysis or the example workflows won't find their nodes.

CategoryData Analysis

Inputs (2)

NameTypeDefaultDescription
dataframeDATAFRAME
axisCOMBO2 options: index, columns

Outputs (1)

NameTypeDescription
DATAFRAMEDATAFRAME