ComfyUI Node

Pandas Cummax

Track the running maximum down a column

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

Pandas Cummax answers a specific, occasionally vital question: "at every point in this sequence, what's the biggest value seen so far?" It computes the cumulative maximum - each output cell is the max of everything up to and including that cell. Think stock charts, model-training curves where you want the best validation score so far, or any "record so far" analysis. It's the kind of calculation that's trivial in pandas and fiddly to get right by hand, which makes it a perfect fit for a one-node wrapper.

The mechanism is dataframe.cummax(axis=...), and the axis choice is the one decision you actually make:

  • axis - an enum with two choices: index or columns.

Here's the naming trap that catches everyone once: "index" in this pack's axis enum means down the rows (pandas axis=0), and "columns" means across the columns (axis=1). So if you want a running max down a vertical column of numbers, pick index - the naming is from pandas' perspective, where the index runs down the page. It feels backwards the first time, and the node doesn't help by using words instead of numbers. Pick wrong and you get the running max across the row instead, which is almost never what you meant.

Inputs and outputs are simple: dataframe (DATAFRAME) plus the axis enum, output a DATAFRAME of the same shape. One note: like all the cumulative nodes, NaN values propagate - a missing value makes the running max stick at NaN until data returns, so clean your data first or you'll wonder why the series goes blank mid-way.

Where it fits

This node pairs naturally with the other cumulative trio in the pack - Cumsum, Cummin, Cumprod - and they're all identical in structure, so if you understand one you understand all four. Cummax is the one you reach for when the record matters more than the sum: best-ever scores, highest-water-mark prices, leaderboard progressions. It's a boring node, but it's the correct boring node.

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. Remember to rename the folder to lowercase data-analysis or the example workflows won't load.

CategoryData Analysis

Inputs (2)

NameTypeDefaultDescription
dataframeDATAFRAME
axisCOMBO2 options: index, columns

Outputs (1)

NameTypeDescription
DATAFRAMEDATAFRAME