# xarray.indexes.RangeIndex.arange

#### *classmethod* RangeIndex.arange(start=None, stop=None, step=None, , coord_name=None, dim, dtype=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/indexes/range_index.py#L200-L297)

Create a new RangeIndex from given start, stop and step values.

`RangeIndex.arange` can be called with a varying number of positional arguments:

- `RangeIndex.arange(stop)`: the index is within the half-open interval [0, stop)
  (in other words, the interval including start but excluding stop).
- `RangeIndex.arange(start, stop)`: the index is within the half-open interval
  [start, stop).
- `RangeIndex.arange(start, stop, step)`: the index is within the half-open interval
  [start, stop), with spacing between values given by step.

#### NOTE
When using a non-integer step, such as 0.1, it is often better to use
[`linspace()`](xarray.indexes.RangeIndex.linspace.html.md#xarray.indexes.RangeIndex.linspace).

#### NOTE
`RangeIndex.arange(start=4.0)` returns a range index in the [0.0, 4.0)
interval, i.e., `start` is interpreted as `stop` even when it is given
as a unique keyword argument.

* **Parameters:**
  * **start** ([`float`](https://docs.python.org/3/builtins/functions.html#float), *optional*) – Start of interval. The interval includes this value. The default start
    value is 0. If `stop` is not given, the value given here is interpreted
    as the end of the interval.
  * **stop** ([`float`](https://docs.python.org/3/builtins/functions.html#float)) – End of interval. In general the interval does not include this value,
    except floating point round-off affects the size of the dimension.
  * **step** ([`float`](https://docs.python.org/3/builtins/functions.html#float), *optional*) – Spacing between values (default: 1.0).
  * **coord_name** (`Hashable`, *optional*) – Name of the (lazy) coordinate variable that will be created and
    associated with the new index. If `None`, the coordinate is named
    as the dimension name.
  * **dim** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Dimension name.
  * **dtype** ([`dtype`](https://numpy.org/doc/stable/reference/generated/numpy.dtype.html#numpy.dtype), *optional*) – The dtype of the coordinate variable (default: float64).

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('9af06f01-e546-4292-9bc3-d70be1ae53eb','6f3e0756-fd0a-4e6d-b296-c353a005519a','c131c40f-e53c-41e3-bb20-2a81655846b7','../lite/tree/../notebooks/index.html?path=18336973_6d42_4cfe_b203_24f2d5ff81e5.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> from xarray.indexes import RangeIndex
```

```pycon
>>> index = RangeIndex.arange(0.0, 1.0, 0.2, dim="x")
>>> ds = xr.Dataset(coords=xr.Coordinates.from_xindex(index))
```

```pycon
>>> ds
<xarray.Dataset> Size: 40B
Dimensions:  (x: 5)
Coordinates:
  * x        (x) float64 40B 0.0 0.2 0.4 0.6 0.8
Data variables:
    *empty*
Indexes:
    x        RangeIndex (start=0, stop=1, step=0.2)
```

<div id="c131c40f-e53c-41e3-bb20-2a81655846b7" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('9af06f01-e546-4292-9bc3-d70be1ae53eb','c131c40f-e53c-41e3-bb20-2a81655846b7')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('9af06f01-e546-4292-9bc3-d70be1ae53eb','c131c40f-e53c-41e3-bb20-2a81655846b7')">Open In Tab</button></div><div id="6f3e0756-fd0a-4e6d-b296-c353a005519a" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
