ComfyUI Node

Pandas To Numpy

The bridge from DataFrame to numpy arrays

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Pandas To Numpy
  • dataframe
  • NDARRAY

DataFrames are great for labeled, tabular thinking. But a lot of the math downstream doesn't care about labels - it wants a plain array. Pandas To Numpy converts a DataFrame into a NumPy ndarray, dropping the column names and index in the process. It's the pack's gateway between the labeled world and the array world.

Here's the context that makes it click. This pack's author split the PyTorch side of the project into a separate extension (ComfyUI-Pt-Wrapper) back in March 2025, precisely so the pandas and tensor worlds could stay cleanly separated. Pandas To Numpy is the friendly end of that split: it hands an NDARRAY to the numpy/tensor side of your graph. The author's own demo pipeline - analyzing the red-channel pixel distribution of a generated image as a histogram - runs data from image tensors through exactly this kind of conversion. If you want to do stats or plotting on numerical data that came from somewhere array-shaped, this is the node that gets you there.

How it works

It's dataframe.to_numpy() with a type check: if what arrives isn't actually a DataFrame, it raises a TypeError rather than silently mangling it. The conversion is positional - the i,j-th element of the array is the value at row i, column j of the frame. Column names and the index are gone; if you need them back, that's a one-way door. Mixed dtypes get coerced into a single array dtype (usually object or float), which is worth remembering.

Inputs and outputs

  • dataframe (DATAFRAME) - the frame to convert.

Output: a single NDARRAY - the numpy representation, wire-compatible with the pack's numpy nodes (Numpy Show, Numpy Squeeze) and the separate PyTorch wrapper extension.

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

  • "PandasToNumpy expects pd.DataFrame." That's the node's own type guard firing - the input wasn't a DataFrame. Series outputs (from Pandas Sum/Pandas Std) won't fit; convert them to a DataFrame first with Pandas Series To Dataframe.
  • Labels disappeared. Expected, and it's one-way. Keep a labeled copy of the frame upstream if you'll need column names later.
  • Mixed-type frame. If your frame mixes numbers and text, the array comes out as object dtype and math on it will misbehave. Convert or drop the non-numeric columns before this node.
CategoryData Analysis

Inputs (1)

NameTypeDefaultDescription
dataframeDATAFRAME

Outputs (1)

NameTypeDescription
NDARRAYNDARRAY