Pandas Fill NA Scalar Float
Patch missing values before they poison your math
- dataframe
- DATAFRAME
Real CSVs have holes. Blank cells come in as NaN, and once NaN is in a float column, your mean is NaN, your sum is NaN, and your plot has a jagged gap. Pandas Fill NA Scalar Float is the quick fix: it replaces every missing value in a DataFrame with a float you specify. Zero if you want a clean baseline, the column mean if you want to be fancy - either way, you un-break the math.
It's the float-flavored half of the fill-NA pair in the ComfyUI-Data-Analysis pack (the other is Pandas Fill NA Scalar Int, for integer data). This is genuinely a data-cleaning-first node: you reach for it right after loading a messy file and before any aggregation or plotting.
How it works
The whole thing is dataframe.fillna(float_scalar) - a pass-through of the pandas method, with the result returned as a fresh DATAFRAME. It fills all missing values in the frame with the one scalar, so no per-column decisions here. If your DataFrame has a mix of float and text columns, the float will be cast into the object cells too; for the common all-numeric case it's exactly what you want.
One quirk straight from the author's own docstring: the node's built-in widget only reliably supports one decimal digit when you type a value directly into the node. For anything more precise - say 3.14159 - the recommended path is to build the value with CDA Float Create and wire it into the float_scalar input. That's the workaround the author ships, and it's a genuine trap if you don't know it.
Inputs and outputs
- dataframe (required,
DATAFRAME) - the frame with holes. Typically from Pandas Load CSV or Pandas Load JSON. - float_scalar (required,
FLOAT, default 0) - the replacement value. Enter it directly (one decimal digit, see above) or drive it from CDA Float Create. - DATAFRAME output - a copy with NaN replaced; the original is untouched.
Where it fits
Typical chain: Pandas Load CSV → Pandas Fill NA Scalar Float → Pandas Mean (or a plot node like MPL Line). It also plays well with Pandas Is NA - run that first if you want to see where the holes are, then decide whether filling with 0 or dropping rows (Pandas Drop NA) is the right move. Filling is the safer default when you need the row count to stay put.
Installing it
Same pack install as everything else here. ComfyUI Manager: search "Data analysis", install ComfyUI-Data-Analysis, restart, reload. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis
mv ComfyUI-Data-Analysis data-analysis # README insists on this folder name
pip install -r data-analysis/requirements.txt
Dependencies are the pack's usual stack - pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl, lxml - none bundled with ComfyUI. No GPU required; the PyTorch wrapper nodes moved to a separate extension in March 2025, so this pack is pure CPU.
Gotchas
- One-decimal-digit widget. Precise floats: build them with CDA Float Create and wire in. The direct field is a trap.
- It fills everything. One scalar across the whole frame. If different columns need different fill values, you'll need multiple fill nodes or to handle columns separately.
- NaN doesn't stay NaN. Check with Pandas Is NA before you decide, because after fillna there's no trace of what was missing.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| dataframe | DATAFRAME | — | |
| float_scalar | FLOAT | 0.00-2147483648–2147483648 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| DATAFRAME | DATAFRAME | — |