Nodes/ComfyUI-huggingface_dataset/πŸ€— Dataset Map Column
ComfyUI Node

πŸ€— Dataset Map Column

Add a column to every row β€” constants, copies, or a row index, all in the graph

By StableLlamaΒ·Created a day agoΒ·Updated a day agoΒ· 1
πŸ€— Dataset Map Column
  • dataset
  • dataset
β—„columnnew_columnβ–Ί
β—„operationconstantβ–Ί
β—„valueβ–Ί

The most common thing you do to a table in real data work isn't filtering - it's adding a column. A stable ID so you can track a row after a shuffle. A flag you want on every record. A copy of another field under a new name because the downstream tool insists on its own key. πŸ€— Dataset Map Column is that operation as a node: it adds (or replaces) one column across every row, with the value computed three ways.

How it works

Under the hood it's datasets map - the Swiss-army transform - but you never write the mapping function. The three operation choices cover the cases people actually hit:

  • constant - every row gets the literal text you type in value. Handy for stamping a version tag, a source label, or a fixed prompt prefix onto a batch before export.
  • copy column - value names an existing column whose values get copied into column. Great when you need the same data under a different key and don't want to rearrange the original.
  • row index - each row gets its 0-based position as an integer. This is the sleeper feature. Give every review an id before you shuffle, and you can still trace samples back to their original position - which is exactly the bookkeeping a training-set builder wants.

column defaults to new_column; set it to a name that already exists and the node replaces that column, dropping the old values first (even across types, the tooltip notes). Output is a new HUGGINGFACE_DATASET with the column added, so it slots into any chain - Map Column β†’ Filter β†’ To Data List is a classic.

One thing the node is not: a free-form Python mapper. If you need text.upper() + column B, this won't do it - the operations are deliberately the three boring, safe ones. That's a feature for a graph environment where a node shouldn't be able to execute arbitrary code per row.

Inputs, briefly

  • column - name to add or replace (default new_column).
  • operation - constant, copy column, or row index.
  • value - literal for constant, source column name for copy column; ignored for row index.

Unlike several nodes in this pack, Map Column works on fully-loaded and streaming datasets, so you can stamp IDs onto a lazy IterableDataset without forcing a full download.

Installing it

Part of the ComfyUI-huggingface_dataset pack (StableLlama). ComfyUI-Manager β†’ search "Hugging Face dataset", or:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-huggingface_dataset
pip install -r requirements.txt

Restart ComfyUI. The only runtime dependency is datasets, installed automatically by Manager.

Gotchas worth knowing

The replacement behavior can surprise you: if column already exists and you pick constant, you're overwriting that column for every row, not appending. Check that you're not clobbering data you need. And if you name the source column itself as the target for copy column (copying text into text), the node still works - it copies from the original before the replace - but it's a no-op you probably didn't intend. Row-index values start at 0, matching Python and datasets, so don't expect 1-based numbering.

CategoryHugging Face πŸ€—

Inputs (4)

NameTypeDefaultDescription
datasetHUGGINGFACE_DATASETDataset whose column to add or replace (from the πŸ€— Dataset Loader or another dataset node).
columnSTRINGnew_columnName of the column to add or replace.
operationCOMBOconstantHow to compute the value: constant, copy column, or row index.
valueSTRINGLiteral value for 'constant', or the source column name for 'copy column'.

Outputs (1)

NameTypeDescription
datasetHUGGINGFACE_DATASETThe dataset with the added or replaced column.