Nodes/ComfyUI-Data-Analysis/Pandas Vertical Split
ComfyUI Node

Pandas Vertical Split

Cut a DataFrame in Half — Your Train/Test Split, in Two Nodes

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Pandas Vertical Split
  • dataframe
  • Top DataFrame
  • Bottom DataFrame
row_integer_position0

You loaded a big CSV, and now you want the first 80% for training and the last 20% as a holdout - or you want to peel off that header row before you plot. Pandas Vertical Split is the scissors: it takes one DataFrame and slices it into two at a row position you pick.

It's the inverse of Pandas Vertical Concat, and it's the node you reach for when you want a quick train/test split or want to chop a dataset before feeding it into plots. One integer field, two outputs, done.

How it works

It's a plain pandas iloc slice on the row index, at the position you give it:

  • Top DataFrame = rows [0, row_integer_position-1]
  • Bottom DataFrame = rows [row_integer_position, end]

Note that "position" here is positional - row 0 is the first row regardless of what the index labels are. If you're used to label-based selection, this trips people up; iloc counts rows, it doesn't care about names.

Inputs and outputs

  • dataframe - the DATAFRAME to split.
  • row_integer_position - where the cut happens. Default 0, range from -1 up. Set it to the number of rows you want on top.

Two outputs come out: Top DataFrame and Bottom DataFrame, both DATAFRAME. The top is always the earlier rows, the bottom is the rest - the order isn't configurable, so plan which side you want first.

Two edge cases worth knowing. At position 0, the top is empty and everything lands in the bottom - the node doesn't stop you, it just slices literally. At -1, the top is all rows except the last and the bottom is exactly the final row, which is a neat trick for dropping off a trailing blank line.

Install

This node ships in the HowToSD/ComfyUI-Data-Analysis pack. In ComfyUI Manager: search "Data analysis" in the Custom Node Manager, install ComfyUI-Data-Analysis, restart, reload the browser. Manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
mv ComfyUI-Data-Analysis data-analysis   # README: example workflows need this name
pip install -r requirements.txt

The README stresses that folder rename - skip it and example workflows will fail to load. No models to download, no GPU needed; the heavy lifting is pandas and matplotlib, which Manager installs for you.

Common issues

The usual complaint is "my split is off by one." Remember it's iloc - row row_integer_position belongs to the bottom frame, not the top. And because it's purely positional, if your frame was sorted or had rows dropped earlier in the graph, the split point moves too. There's no shuffle here; if you want a randomized split, sort or shuffle first with other nodes in the pack. Finally, both outputs stay in the same graph - the split doesn't mutate the original, so you can branch and use the full frame elsewhere without worry.

CategoryData Analysis

Inputs (2)

NameTypeDefaultDescription
dataframeDATAFRAME
row_integer_positionINT0-1–2147483648

Outputs (2)

NameTypeDescription
Top DataFrameDATAFRAME
Bottom DataFrameDATAFRAME