Skip to content

Commit

Permalink
DOC: add example for reindex (#4956)
Browse files Browse the repository at this point in the history
* DOC: add example for reindex

* rm white space

* use arange
  • Loading branch information
raybellwaves authored Feb 26, 2021
1 parent 835a53e commit f74c446
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,26 @@ def reindex(
Another dataset array, with this array's data but replaced
coordinates.
Examples
--------
Reverse latitude:
>>> da = xr.DataArray(
... np.arange(4),
... coords=[np.array([90, 89, 88, 87])],
... dims="lat",
... )
>>> da
<xarray.DataArray (lat: 4)>
array([0, 1, 2, 3])
Coordinates:
* lat (lat) int64 90 89 88 87
>>> da.reindex(lat=da.lat[::-1])
<xarray.DataArray (lat: 4)>
array([3, 2, 1, 0])
Coordinates:
* lat (lat) int64 87 88 89 90
See Also
--------
DataArray.reindex_like
Expand Down

0 comments on commit f74c446

Please sign in to comment.