Numpy Squeeze
Strip the useless size-1 dimensions out of your array
- array
- NDARRAY
Numpy Squeeze fixes a classic data-shape annoyance: arrays that come out of a pipeline wearing a pointless 1 dimension. An array that should be (3,) arrives as (1, 3), or (1, 1, 3), and every downstream node either chokes or silently does the wrong thing. This node removes the specified dimension when it has size 1, so your shapes match what the rest of the workflow expects.
It's part of HowToSD's ComfyUI-Data-Analysis pack - the Numpy reshaping utility that pairs with the pack's Numpy create and show nodes. The author's docstring is unusually honest about its limits: it removes one dimension, and "specifying a tuple of dimensions is not supported."
How it works
The implementation is a single call: np.squeeze(array, dim). Two inputs: the array and an integer dim (default -1, range -1 to 10) telling it which axis to strip. And here's the subtle part that bites people: this is not the same as bare np.squeeze().
- Plain
np.squeeze()removes all size-1 dimensions at once. - This node, by always passing a
dim, removes exactly one axis - the one you name - and only if that axis is size 1.
With the default dim=-1, it targets the last axis. On a (3, 1) array, -1 correctly gives you (3,). But on a (1, 3) array, the last axis is size 3, so np.squeeze raises a ValueError - "cannot select an axis to squeeze out which has size not equal to one." If you're coming from the "squeeze just tidies my array" mental model, that error is the first thing to know.
Inputs and outputs
- array (required,
NDARRAY) - the array to reshape. - dim (required,
INT, default-1) - the axis to remove. Set it to the position of the size-1 dimension; use-1for the last one. - NDARRAY output - the squeezed array.
When you'd use it
The common case is cleaning up array shapes between the pack's nodes: Numpy Float Create → Numpy Squeeze → Pandas Create From Numpy, or before feeding a (1, n) array into a computation that expects (n,). Pair it with Numpy Show to confirm the shape before and after - that's the debugging habit this pack rewards.
Installing it
Pack install, once. 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 # README: examples expect this folder name
pip install -r data-analysis/requirements.txt
Dependencies: pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl, lxml. No GPU, no models. PyTorch nodes live in ComfyUI-Pt-Wrapper since the March 2025 split.
Gotchas
dim=-1isn't "remove all." It removes the last axis only, and errors if that axis isn't size 1. To strip a different axis, pass its position.- No tuple support. You can't squeeze several dimensions in one call - chain two squeeze nodes instead.
- Error means wrong axis, not broken array. The ValueError is numpy telling you that axis isn't removable; check the shape with Numpy Show and pick the right
dim.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| array | NDARRAY | — | |
| dim | INT | -1-1–10 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| NDARRAY | NDARRAY | — |