Pandas Cumprod
Running products, with a warning about compound explosions
- dataframe
- DATAFRAME
Pandas Cumprod computes the running product - each output cell is everything up to and including that cell, multiplied together. It's the node you reach for when values compound: cumulative growth ("if I multiply these daily returns, what's the total return so far?"), probability chains where a running product gives you the chance of surviving this long, or any "this times that times the next" accumulation.
The mechanism is the same shape as the other cumulative nodes:
df_out = dataframe.cumprod(axis=0 if axis == "index" else 1)
with the familiar axis enum - index (down the rows, pandas axis=0) or columns (across, axis=1). And yes, the naming is backwards from intuition in exactly the same way: pick index to run the product down a vertical column of numbers. This is the one input, besides the dataframe itself, that you'll set.
The thing nobody warns you about
Cumulative products get out of hand fast, and this node won't protect you. Multiply a column of 1.05s ten times and you get 1.63; multiply a column of 2.0s ten times and you get 1024; feed it a column with a single zero and everything after it becomes zero forever. Compound values with big magnitude can overflow into inf or -inf without an error. So before you wire this in, ask whether a running sum (Pandas Cumsum) is what you actually want - it often is, and it behaves far more gently. Cumprod is the right tool for growth rates and probability chains, not for arbitrary sequences where you just want "things so far."
NaNs behave like the rest of the pack's cumulative nodes: one missing value pins the running product at NaN until a non-missing value appears. Clean the frame with Pandas Drop NA or Fill NA first if that matters.
Output is a DATAFRAME of the same shape, running products per cell. It's a utility node - deliberately nothing more - and it chains straight into plotting or Show DataFrame.
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 model downloads. If Manager's dependency install stumbles, pip install pandas covers the whole pack.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| dataframe | DATAFRAME | — | |
| axis | COMBO | 2 options: index, columns |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| DATAFRAME | DATAFRAME | — |