Nodes/ComfyUI-Data-Analysis/Pandas Sub Scalar Float
ComfyUI Node

Pandas Sub Scalar Float

Subtract one float from an entire DataFrame

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Pandas Sub Scalar Float
  • dataframe
  • DATAFRAME
float_scalar0.00

Pandas Sub Scalar Float subtracts a single floating-point number from every cell in a DataFrame. That's the whole job: one float, applied across the whole frame, cell by cell. It's the subtraction flavor of the pack's scalar math family (there's an integer twin in Pandas Sub Scalar Int, plus add, divide, multiply, power variants), and it exists because "shift my whole dataset down by a constant" is a shockingly common operation.

Where it shows up: centering data before analysis. You often want to de-mean a column or a whole frame - subtract the mean so the values sit around zero - and if your mean happens to be a float (they usually are), this is the node. Same trick applies to removing a known offset, like subtracting a baseline measurement from every row. In a ComfyUI-Data-Analysis workflow you'd typically pull the offset out of a Pandas Mean or Pandas Summary upstream, type it into the field, and feed the shifted frame into a plot or a Pandas Std to check the spread.

How it works

The implementation is literally dataframe - float_scalar - numpy/pandas broadcasting, one value subtracted from every cell. No axis choice, no column selection, nothing subtle. Worth one note: if your DataFrame is all integers, subtracting a float quietly promotes the result to float dtype. That's usually fine and sometimes exactly what you want, but it can surprise you if you were expecting to keep integers.

Inputs and outputs

  • dataframe (DATAFRAME) - the frame to shift.
  • float_scalar (FLOAT, default 0) - the number to subtract from every cell.

Output: a single DATAFRAME, shifted down by the scalar.

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

  • Everything turned float. Expected - subtract a float and pandas promotes the dtype. If you need integers back, cast with Pandas As Int.
  • My string column broke. This is numeric arithmetic; subtracting a number from text raises. Keep this node on numeric frames, or coerce non-numeric cells first (the Pandas Sin/Pandas Tan nodes show the pack's coerce-to-NaN trick).
  • Wrong offset? It's a plain constant - there's no way to make it column-specific here. For per-column subtraction, that's what Pandas Sub Series or Pandas Sub (DataFrame-to-DataFrame) is for.
CategoryData Analysis

Inputs (2)

NameTypeDefaultDescription
dataframeDATAFRAME
float_scalarFLOAT0.00-2147483648–2147483648

Outputs (1)

NameTypeDescription
DATAFRAMEDATAFRAME