π€ Dataset Filter
Filter a Hugging Face dataset by column β without writing a single lambda
- dataset
- dataset
Say you've loaded stanfordnlp/imdb into your graph and you only want the positive reviews - label == 1 - because that's what your downstream step needs. In Python that's a one-line lambda; in ComfyUI there was never a place to put that line. π€ Dataset Filter is the place. It keeps the rows of a column that satisfy a condition you pick from dropdowns and type a value into, which turns a code-style operation into a node you can rewire without touching code.
How it works
This is a thin declarative wrapper over datasets.Dataset.filter (and its streaming twin), where the predicate is built for you from three widgets instead of a function. The dataset you feed in comes from the π€ Dataset Loader or any other node in the pack, and you get a filtered dataset back out - so filters chain with shuffles, takes, and column ops before anything is materialized.
The operator list is where the node earns its keep. You get the full equality/ordering set (==, !=, <, <=, >, >=), plus text operators (contains, not contains, starts with, ends with), membership (in / not in), and null checks (is null / is not null). Two details worth knowing:
- The
valuetext is coerced to the column's type. Numeric columns compare against plain numbers, so a"0.8"typed into the box genuinely compares numerically, not lexicographically. in/not intake a comma-separated value list, andis null/is not nullignore the value box entirely.
It works on both fully-loaded and streaming datasets, which is more than you can say for most of the loaded-only nodes in this pack.
The inputs that matter
column- which column the condition runs against. Typo it and you get an error naming the missing column.operator- the 14-choice dropdown. This is the whole mechanism; nothing else in the pack gives you this vocabulary as a graph node.value- the thing to compare (comma-separated forin/not in, ignored for null checks).
Output is one dataset socket: the same opaque HUGGINGFACE_DATASET your loader emitted, just with fewer rows. Feed it onward into another π€ node, or into π€ Dataset To Data List / To LIST when you finally want concrete Python data.
Installing it
This node ships in the StableLlama/ComfyUI-huggingface_dataset pack, so one install gets you it plus the loader and every other π€ node. ComfyUI-Manager: search "Hugging Face dataset". Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-huggingface_dataset
pip install -r requirements.txt # just `datasets`
Restart ComfyUI. No API key, no model downloads - the only dependency is the datasets Python package, and Manager installs it for you.
Where people get burned
The big gotchas are both about what "filter" doesn't do. First, it never touches rows you don't have: if you filtered upstream with is null on a column that doesn't contain nulls, you keep everything - that's correct, but it reads like the filter silently failed. Second, don't confuse the streaming picture: filtering a streaming dataset is fine and stays lazy, but if you're only going to inspect a handful of matching rows on a huge corpus, put a Take after the filter and materialize small. A filter alone on a non-streaming load has already paid for the full download.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| dataset | HUGGINGFACE_DATASET | Dataset to filter rows of (from the π€ Dataset Loader or another dataset node). | |
| column | STRING | Column the condition is evaluated on. | |
| operator | COMBO | == | Comparison: == != < <= > >=, contains / not contains / starts with / ends with, in / not in, is null / is not null. |
| value | STRING | Value to compare (comma-separated for 'in' / 'not in'); ignored for the null checks. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| dataset | HUGGINGFACE_DATASET | The dataset with only the matching rows. |