Skip to content

Commit aa1d1d1

Browse files
authored
Docs: indexing.rst finetuning (#6685)
1 parent a7799fb commit aa1d1d1

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

doc/user-guide/indexing.rst

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ looked-up from the coordinate values.
2626
Dimensions of xarray objects have names, so you can also lookup the dimensions
2727
by name, instead of remembering their positional order.
2828

29-
Thus in total, xarray supports four different kinds of indexing, as described
29+
Quick overview
30+
--------------
31+
32+
In total, xarray supports four different kinds of indexing, as described
3033
below and summarized in this table:
3134

3235
.. |br| raw:: html
@@ -93,7 +96,7 @@ in the range '2000-01-01':'2000-01-02' along the first coordinate `time`
9396
and with 'IA' value from the second coordinate `space`.
9497

9598
You can perform any of the label indexing operations `supported by pandas`__,
96-
including indexing with individual, slices and arrays of labels, as well as
99+
including indexing with individual, slices and lists/arrays of labels, as well as
97100
indexing with boolean arrays. Like pandas, label based indexing in xarray is
98101
*inclusive* of both the start and stop bounds.
99102

@@ -113,32 +116,33 @@ Indexing with dimension names
113116
With the dimension names, we do not have to rely on dimension order and can
114117
use them explicitly to slice data. There are two ways to do this:
115118

116-
1. Use a dictionary as the argument for array positional or label based array
117-
indexing:
119+
1. Use the :py:meth:`~xarray.DataArray.sel` and :py:meth:`~xarray.DataArray.isel`
120+
convenience methods:
118121

119122
.. ipython:: python
120123
121124
# index by integer array indices
122-
da[dict(space=0, time=slice(None, 2))]
125+
da.isel(space=0, time=slice(None, 2))
123126
124127
# index by dimension coordinate labels
125-
da.loc[dict(time=slice("2000-01-01", "2000-01-02"))]
128+
da.sel(time=slice("2000-01-01", "2000-01-02"))
126129
127-
2. Use the :py:meth:`~xarray.DataArray.sel` and :py:meth:`~xarray.DataArray.isel`
128-
convenience methods:
130+
2. Use a dictionary as the argument for array positional or label based array
131+
indexing:
129132

130133
.. ipython:: python
131134
132135
# index by integer array indices
133-
da.isel(space=0, time=slice(None, 2))
136+
da[dict(space=0, time=slice(None, 2))]
134137
135138
# index by dimension coordinate labels
136-
da.sel(time=slice("2000-01-01", "2000-01-02"))
139+
da.loc[dict(time=slice("2000-01-01", "2000-01-02"))]
137140
138141
The arguments to these methods can be any objects that could index the array
139142
along the dimension given by the keyword, e.g., labels for an individual value,
140143
Python :py:class:`slice` objects or 1-dimensional arrays.
141144

145+
142146
.. note::
143147

144148
We would love to be able to do indexing with labeled dimension names inside

0 commit comments

Comments
 (0)