Dataset.iter_rows(*, prefetch_blocks: int = 0) Iterator[Union[ray.data.block.T, ray.data.row.TableRow]][source]#

Return a local row iterator over the dataset.

If the dataset is a tabular dataset (Arrow/Pandas blocks), dict-like mappings TableRow are yielded for each row by the iterator. If the dataset is not tabular, the raw row is yielded.


>>> import ray
>>> for i in ray.data.range(1000000).iter_rows(): 
...     print(i) 

Time complexity: O(1)


prefetch_blocks – The number of blocks to prefetch ahead of the current block during the scan.


A local iterator over the entire dataset.