ray.data.Dataset.take#
- Dataset.take(limit: int = 20) List[Dict[str, Any]][source]#
Return up to
limitrows from theDataset.This method is useful for inspecting data.
Warning
take()moves up tolimitrows to the caller’s machine. Iflimitis large, this method can cause anOutOfMemoryerror 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
limitrows from the dataset.
See also
take_all()Call this method to return all rows.