ray.data.range#

ray.data.range(n: int, *, parallelism: int = - 1) ray.data.dataset.Dataset[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={id: int64})
>>> ds.map(lambda x: {"id": x["id"] * 2}).take(4) 
[{"id": 0}, {"id": 2}, {"id": 4}, {"id": 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 producing the integers.

PublicAPI: This API is stable across Ray releases.