ray.data.Dataset.take#

Dataset.take(limit: int = 20) List[Dict[str, Any]][source]#

Return up to limit rows from the Dataset.

This method is useful for inspecting data.

Warning

take() moves up to limit rows to the caller’s machine. If limit is large, this method can cause an OutOfMemory error on the caller.

Note

This operation will trigger execution of the lazy transformations performed on this dataset.

Examples

>>> import ray
>>> ds = ray.data.range(100)
>>> ds.take(3)
[{'id': 0}, {'id': 1}, {'id': 2}]

Time complexity: O(limit specified)

Parameters:

limit – The maximum number of rows to return.

Returns:

A list of up to limit rows from the dataset.

See also

take_all()

Call this method to return all rows.