ComfyUI Node

Pandas Sum

Column totals, as a Series — the SQL SUM of the graph

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

Pandas Sum adds up each column of a DataFrame and returns the totals as a Series. It's the "how many hits did everyone get combined" node - the natural first step of the author's own baseball tutorial, where you want per-column totals before you do anything clever. If you've used the other summary nodes in this pack, this is the same shape: DataFrame in, one Series out, one number per column.

Reach for it whenever a grand total is the answer, or when a total is a stepping stone. Totals feed Pandas Sub Series for per-column de-meaning, they compare across frames ("is this week's total bigger?"), and they show up in bar charts as the headline number. It's the SQL SUM of the ComfyUI graph, minus the GROUP BY.

How it works

It's a wrapper over dataframe.sum(). Pandas' default behavior, which this inherits: sum down each column (axis 0), skip NaN values, and return a Series indexed by column name. String columns get concatenated rather than summed numerically - that's pandas being pandas, not a bug - so keep this node on numeric data unless you're deliberately smushing text together.

Inputs and outputs

  • dataframe (DATAFRAME) - the frame to total.

Output: a single PDSERIES with each column's sum. Wire it into Pandas Show Series to read it, Pandas Series To Dataframe to get it back as a table, Pandas Sub Series to subtract those totals from a frame, or a plotting node to visualize.

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

  • My "sum" is a long string. That column is text, and pandas concatenates strings under sum(). Convert the column to numeric first (Pandas As Float or Pandas As Int).
  • NaN in, NaN out. sum() skips NaN by default, so if the input was all-NaN the result is 0-ish or NaN - check whether your frame actually had values upstream.
  • It's per column, not per row. If you wanted row totals, that's a different operation - this pack's sum always runs down columns. To check rows, Pandas Transpose first if you must.
CategoryData Analysis

Inputs (1)

NameTypeDefaultDescription
dataframeDATAFRAME

Outputs (1)

NameTypeDescription
PDSERIESPDSERIES