ComfyUI Node

Pandas Head

A quick peek at your first rows, ComfyUI-style

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

Pandas Head is the df.head() of the ComfyUI world: take a DataFrame, keep the first N rows, pass the rest along. In a notebook you'd type df.head() out of reflex to make sure your data actually loaded. In ComfyUI there's no console, so this node is the closest thing to that reflex - a way to trim a frame down to a manageable slice.

Two distinct jobs, and it's worth not confusing them. Job one: shrinking. You loaded a giant CSV and you only want the first handful of rows to, say, plot a sample. Set rows to 10 and downstream nodes see a 10-row frame. Job two: verifying. Feed the output into Pandas Show DataFrame and you get a readable table of what your data actually looks like - column names, types, whether that first row is garbage. The rows widget caps at 50, which is fine for eyeballing and not enough for real analysis, so treat this as a preview tool, not a data-splitting tool.

How it works

The node calls dataframe.head(rows) and returns the result. That's pandas' native head: the first rows rows, in order, with labels intact. It never mutates the input - you get a new, smaller frame, and the original is untouched, which is what you want when you're branching a workflow into "preview" and "full data" paths from one load node. Set rows to 0 and you get an empty frame, which is occasionally a useful way to stub something out.

Where people trip: head takes the first rows of whatever order the frame is in. If your CSV is unsorted, "first 10" tells you nothing about the distribution - it just shows you the top of the file. For a representative sample you'd want something like Pandas Value Counts or a shuffle first. Head is a glance at the beginning of the data, not a sample.

Inputs and outputs

  • dataframe (required, DATAFRAME) - the frame to trim.
  • rows (required, INT, default 10, max 50) - how many rows to keep.
  • DATAFRAME output - the first rows rows.

Installing it

One pack, one install. ComfyUI Manager → search "Data analysis" → install ComfyUI-Data-Analysis → restart → reload the browser. Manual:

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

Requirements: pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl, lxml. No GPU, no model downloads. Head is one of the safest nodes in the pack - a one-line pandas wrapper - so if it's erroring, the frame feeding it is the problem, not the node. Check the column names and shape with the pack's introspection nodes before you trim.

CategoryData Analysis

Inputs (2)

NameTypeDefaultDescription
dataframeDATAFRAME
rowsINT100–50

Outputs (1)

NameTypeDescription
DATAFRAMEDATAFRAME