ComfyUI Node

Pandas As Int

Make the whole frame integer — with NaN still allowed to exist

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

Pandas As Int converts every cell in a DataFrame to an integer. Same family as Pandas As Float, but with one quiet difference that saves your data: it converts to pandas' nullable Int64 type, which means missing values stay as NaN instead of vanishing. That's a bigger deal than it sounds, because plain pandas integer columns can't hold NaN at all - they'd silently force you into floats. This node deliberately doesn't let that happen.

How it works

It runs pd.to_numeric(errors='coerce') then casts to 'Int64'. Unparseable cells become NaN, parseable ones become integers, and the capital-I Int64 keeps the NaNs around legally. Anything that can't be a number gets coerced to NaN rather than raising - same philosophy as the float twin, so a messy CSV won't halt your run.

One behavior to be aware of: floats get truncated toward zero. 3.9 becomes 3, not 4. If you need rounding rather than truncation, do that in a math step first and feed this node the rounded values.

Inputs and outputs

  • dataframe - the frame to convert (DATAFRAME)
  • Output: a DATAFRAME of the same shape, all integer (or NaN)

Nothing else on the node. Clean and minimal.

When to reach for it

Anywhere whole numbers matter: index columns, counts, batch sizes, row positions, or feeding integers into nodes downstream that expect INT-typed values (like the index fields on the pack's Pandas At family). If you're about to do something where floats would be noise - plotting a histogram of counts, joining on an ID column - coercing everything to int first keeps your downstream math honest.

Installing it

Ships with ComfyUI-Data-Analysis (Hide Inada / HowToSD.com). Manager: search Data Analysis → install → restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
mv ComfyUI-Data-Analysis data-analysis
pip install -r data-analysis/requirements.txt

No GPU needed; pandas comes from requirements.txt.

Gotchas

Two things to keep an eye on. First, truncation - check whether you actually want 3.9 → 3. Second, the nullable Int64 behavior can surprise you if you're used to classic pandas: a column that had any missing values before conversion may come out as Int64 rather than plain int64, and some old-school pandas operations (or nodes that assume plain ints) may not like that. In practice, inside this pack it's fine - the nodes accept the type happily.

CategoryData Analysis

Inputs (1)

NameTypeDefaultDescription
dataframeDATAFRAME

Outputs (1)

NameTypeDescription
DATAFRAMEDATAFRAME