Pandas Horizontal Split
Cut a wide table into two narrower ones
- dataframe
- Left DataFrame
- Right DataFrame
Pandas Horizontal Split is the inverse of Pandas Horizontal Concat: it takes one wide DataFrame and cuts it into two narrower ones at a column boundary you specify. Everything left of the cut becomes the "Left DataFrame," everything from the cut on becomes the "Right DataFrame." If your loaded table has forty columns and you only care about a handful, or you want to split a features frame from a labels frame, this is the node - it's also a stepping stone the pack's own docs recommend before converting to NumPy or tensors.
How it works
The cut point is column_integer_position - a 0-based column position. The left output is dataframe.iloc[:, :position] (columns 0 through position-1) and the right is dataframe.iloc[:, position:] (position through the end). Set it to 3 and you get columns [0, 1, 2] on the left and [3, 4, 5, …] on the right. It's positional, not by name - to split on a named column you'd use Pandas Select Columns instead.
Two things to know. First, negative positions work, because pandas iloc supports them: -1 puts everything except the last column on the left and the last column on the right. That's the fast way to peel a trailing label column off a frame - and it's exactly the move the Pandas Feature Split To Numpy node automates for you. Second, the output sockets are literally named "Left DataFrame" and "Right DataFrame," which reads a little stilted but makes it obvious which is which in a busy graph. The split never modifies the original - you get two new frames and the input stays intact.
One honest caveat: this splits by column count, so both outputs keep the full row count. If you're trying to split rows (train/test, halves of a dataset), you want the pack's Pandas Vertical Split node instead - "horizontal" in this pack's vocabulary is about columns, and the naming has burned more than one person.
Inputs and outputs
- dataframe (required,
DATAFRAME) - the frame to split. - column_integer_position (required,
INT, default 0) - the 0-based column boundary; negative counts from the end. - Left DataFrame (
DATAFRAME) - columns before the cut. - Right DataFrame (
DATAFRAME) - columns from the cut onward.
Installing it
Installed with the pack: 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
pip install -r data-analysis/requirements.txt
Requirements: pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl, lxml. No GPU, no model downloads. A too-large column_integer_position just yields an empty frame on one side rather than an error - pandas slices happily past the end - so check your column count with Pandas Columns if a side comes back empty.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| dataframe | DATAFRAME | — | |
| column_integer_position | INT | 0-1–2147483648 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| Left DataFrame | DATAFRAME | — |
| Right DataFrame | DATAFRAME | — |