ray.data.Dataset.limit#
- Dataset.limit(limit: int) 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 newDataset
pointing to the truncated distributed data.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.