ray.data.range#

ray.data.range(n: int, *, parallelism: int = - 1) ray.data.dataset.Dataset[int][source]#

Create a dataset from a range of integers [0..n).

Examples

>>> import ray
>>> ds = ray.data.range(10000) 
>>> ds 
Dataset(num_blocks=200, num_rows=10000, schema=<class 'int'>)
>>> ds.map(lambda x: x * 2).take(4) 
[0, 2, 4, 6]
Parameters
  • n – The upper bound of the range of integers.

  • parallelism – The amount of parallelism to use for the dataset. Parallelism may be limited by the number of items.

Returns

Dataset holding the integers.

PublicAPI: This API is stable across Ray releases.