Pandas Feature Split To Numpy
The ML-prep node that collapses four nodes into one
- dataframe
- feature
- label
If you're using this pack to prep data for a machine-learning step, this is the node you'll actually remember. Pandas Feature Split To Numpy takes a DataFrame and splits it into the classic ML pair: a feature array (the columns you train on) and a label array (the column you're trying to predict). Both come out as NumPy ndarrays, which is what most sklearn-style workflows want.
The author's own docstring calls out exactly why it exists: without it, you'd build a mini-graph of a Horizontal Split, then a To Numpy conversion, then a Numpy Squeeze to collapse the label into one dimension. The screenshot in the docs shows this node replacing that whole tangle. It's a genuinely good consolidation - this is the kind of node a pack earns its keep with.
How it works
The split point is label_integer_position - the column position (0-based) that holds your label. Default is -1, which pandas-style means "the last column," and that default is the right choice for the common layout where you've appended your target column on the right. If you pass a negative index, the node adds the column count to it first, so -2 means "second to last."
Everything except the label becomes features, concatenated into one 2D array. The label comes out as its own array, and output_1d_label (default on) flattens it to a single dimension via .ravel() - that's the squeeze step folded in, and it's what most sklearn fit calls expect as y. Turn it off and you get a 2D label, for the cases where your target is itself multidimensional.
There's a real guard here: if label_integer_position resolves past the end of the columns, the node raises a clear ValueError instead of silently slicing garbage. Negative indices past the start can also go out of bounds, so when your frame changes shape, re-check this number.
Inputs and outputs
- dataframe (required,
DATAFRAME) - the frame to split. - label_integer_position (required,
INT, default-1) - which column is the label;-1= last. - output_1d_label (required,
BOOLEAN, default on) - flatten the label to 1D. - feature output (
NDARRAY) - 2D array of all non-label columns. - label output (
NDARRAY) - the label column, 1D by default.
Wire feature and label into any node that accepts the pack's ndarray socket - there's a NumPy wrapper section for exactly this, and the pack's scikit-learn dependency (listed in requirements) is the hint that training-adjacent work is the intended downstream.
Installing it
Standard pack install - 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 are pandas, numpy (via pandas), matplotlib, seaborn, scipy, scikit-learn, openpyxl, lxml. No GPU, no model downloads. If the node fails to appear, it's the same old story: requirements.txt didn't get installed into the Python environment ComfyUI runs under.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| dataframe | DATAFRAME | — | |
| label_integer_position | INT | -1-10–1024 | — |
| output_1d_label | BOOLEAN | true | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| feature | NDARRAY | — |
| label | NDARRAY | — |