🤗 Dataset Select Rows:
HFDatasetSelect keeps specific rows from a fully loaded Hugging Face dataset, giving you a smaller dataset focused on the examples you want to work with. It uses the Hugging Face dataset’s select method, so it is useful for inspecting a few examples, creating a small test subset, or choosing a particular sequence of rows for an AI art workflow. It does not work with streaming datasets; the dataset must be fully loaded first.
🤗 Dataset Select Rows Input Parameters:
dataset
The Hugging Face dataset from which you want to keep rows. Connect the dataset output of the 🤗 Dataset Loader or another dataset node, not a list of individual rows. This input must be a fully loaded dataset with a select method; a streaming dataset cannot be used. No default, minimum, or maximum is specified for this input.
indices
A text expression specifying which row positions to keep. Enter individual zero-based row numbers separated by commas, such as 0, 2, 4; a slice such as 0:100; a stepped slice such as 0:100:2; or a combination separated by commas. In a slice, the stop position is excluded, and leaving it blank, as in 10:, continues to the end of the dataset. The order of the positions you specify determines the selection passed to the dataset. The default is 0:100. No minimum or maximum text length is specified, but every selected row number must be within the dataset’s range, and a slice step cannot be zero.
🤗 Dataset Select Rows Output Parameters:
dataset
A Hugging Face dataset containing only the rows specified by indices. You can connect it to another dataset node to continue working with the selected examples. The output is a dataset object, not an expanded list of its rows.
🤗 Dataset Select Rows Usage Tips:
- Disable
streamingon the 🤗 Dataset Loader before connecting its dataset to this node; selection requires a fully loaded dataset. - Use
0:10to work with the first ten rows, or0:100:2to keep every other row among the first 100 positions. - Use
0, 5, 12when you know the exact examples you want. Row numbering starts at zero, so0is the first row. - Check your dataset’s length before using the default
0:100on a small dataset. If it has fewer than 100 rows, use an open-ended slice such as0:instead. - Keep selections small when you only need a quick test subset; this makes subsequent work with that subset more manageable.
🤗 Dataset Select Rows Common Errors and Solutions:
This operation needs a fully-loaded (materialized) dataset, but the input is a streaming one (datasets.IterableDataset).
- Explanation: The connected dataset is streaming, but this node needs to know the available row positions before selecting them.
- Solution: Disable
streamingon the Hugging Face Dataset Loader that created the dataset, then run the workflow again.
The value passed to this node is not a Hugging Face dataset (it has no 'select' method).
- Explanation: The connected value cannot perform dataset row selection. This can happen if you connect a list of rows rather than the dataset itself.
- Solution: Connect the
datasetoutput of the 🤗 Dataset Loader or another dataset node.
Provide row indices, e.g. '0,2,4' or a slice like '0:100' or '0:100:2'.
- Explanation: The
indicesfield is empty or contains only commas and spaces. - Solution: Enter at least one row number or slice, such as
0or0:.
Bad row index '…': not an integer.
- Explanation: An individual row entry contains text that is not a whole number.
- Solution: Replace it with a numeric row position, and separate multiple positions with commas.
Bad row index '…' (part '…' is not an integer).
- Explanation: The start, stop, or step in a slice is not a whole number.
- Solution: Use a slice such as
0:100:2, or leave a slice component blank where appropriate, as in10:.
Bad row slice '…': use 'start:stop[:step]'.
- Explanation: A slice has too many colon-separated parts.
- Solution: Use no more than a start, stop, and optional step, such as
0:100:2.
Bad row slice '…': step cannot be 0.
- Explanation: A step of zero cannot advance through row positions.
- Solution: Use a nonzero step, such as
0:100:2, or omit the step.
Row index … is out of range (dataset has … rows).
- Explanation: At least one selected position is negative or beyond the last available row. A slice can also produce an invalid position; for example, the default
0:100exceeds a dataset with fewer than 100 rows. - Solution: Choose positions from
0through one less than the dataset’s row count. For a subset that runs to the end regardless of length, use an open-ended slice such as0:.
