Pandas Div Series
Divide every column by one Series, the normalization move
- a_dataframe
- b_series
- DATAFRAME
Pandas Div Series is the middle option in the pack's division trio, and it's the one people underrate. Where Pandas Div needs a whole second DataFrame and the scalar nodes only handle a single number, this one divides a DataFrame by a one-dimensional Series - which is exactly the shape of "divide each row by that row's weight," "divide every column by the row totals," or "normalize each column by its per-row denominator." One Series, applied across the whole table.
Mechanism:
df_out = a_dataframe.div(b_series)
Inputs: a_dataframe (DATAFRAME, the numerator) and b_series (PDSERIES, the denominator). Output: a DATAFRAME. This is pandas' aligned division again, and the Series is aligned to the DataFrame by index - so a Series with index labels ["a", "b", "c"] divides rows a, b, c of every column, no matter what order the rows are in. That alignment is the feature, and it's also the thing that will bite you.
The alignment trap, made personal
Because alignment happens on labels, a Series whose index doesn't match the DataFrame's rows produces NaN everywhere it can't find a match. The classic mistake: you build a Series from a list with Pandas Create Series From List, which gives it a plain 0-based index, then feed it into a DataFrame whose index is something else entirely (a player name, a date). Nothing lines up, and every division result comes out NaN. If your output is a wall of missing values, check that the Series index labels match the DataFrame index labels - not the order, the labels.
Divisions by zero still produce inf rather than errors, so if your Series contains zeros, expect infinities and handle them before plotting.
When this beats the alternatives
Use it when the denominator is per-row data - per-row totals, per-row weights, per-row baseline. The mental rule of thumb for the trio:
- whole table ÷ whole table → Pandas Div
- whole table ÷ one number → Pandas Div Scalar Float / Int
- whole table ÷ per-row values → Pandas Div Series (this one)
Build the Series with Pandas Create Series From Dict if you want labeled rows, or From List if 0-based indexing happens to match your DataFrame. Either way it's the correct tool for a whole class of normalization problems that the other two can't express.
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 files.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| a_dataframe | DATAFRAME | — | |
| b_series | PDSERIES | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| DATAFRAME | DATAFRAME | — |