MCPcopy Create free account
hub / github.com/ray-project/ray / iter_rows

Method iter_rows

python/ray/data/iterator.py:315–343  ·  view source on GitHub ↗

Return a local row iterable over the dataset. If the dataset is a tabular dataset (Arrow/Pandas blocks), dicts are yielded for each row by the iterator. If the dataset is not tabular, the raw row is yielded. Examples: >>> import ray >>> datas

(self)

Source from the content-addressed store, hash-verified

313
314 @PublicAPI
315 def iter_rows(self) -> Iterable[Dict[str, Any]]:
316 """Return a local row iterable over the dataset.
317
318 If the dataset is a tabular dataset (Arrow/Pandas blocks), dicts
319 are yielded for each row by the iterator. If the dataset is not tabular,
320 the raw row is yielded.
321
322 Examples:
323 >>> import ray
324 >>> dataset = ray.data.range(10)
325 >>> next(iter(dataset.iterator().iter_rows()))
326 {'id': 0}
327
328 Time complexity: O(1)
329
330 Returns:
331 An iterable over rows of the dataset.
332 """
333 batch_iterable = self._iter_batches(
334 batch_size=None, batch_format=None, prefetch_batches=1
335 )
336
337 def _wrapped_iterator():
338 for batch in batch_iterable:
339 batch = BlockAccessor.for_block(BlockAccessor.batch_to_block(batch))
340 for row in batch.iter_rows(public_row_format=True):
341 yield row
342
343 return _IterableFromIterator(_wrapped_iterator)
344
345 @abc.abstractmethod
346 @PublicAPI

Callers 1

_wrapped_iteratorMethod · 0.45

Calls 2

_iter_batchesMethod · 0.95

Tested by

no test coverage detected