ray.data.Dataset.limit#

Dataset.limit(limit: int) ray.data.dataset.Dataset[source]#

Truncate the dataset to the first limit rows.

Unlike take(), this method doesn’t move data to the caller’s machine. Instead, it returns a new Dataset pointing to the truncated distributed data.

Note

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

Examples

>>> import ray
>>> ds = ray.data.range(1000)
>>> ds.limit(5).count()
5

Time complexity: O(limit specified)

Parameters

limit – The size of the dataset to truncate to.

Returns

The truncated dataset.