@@ -26,7 +26,10 @@ looked-up from the coordinate values.
26
26
Dimensions of xarray objects have names, so you can also lookup the dimensions
27
27
by name, instead of remembering their positional order.
28
28
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
30
33
below and summarized in this table:
31
34
32
35
.. |br | raw :: html
@@ -93,7 +96,7 @@ in the range '2000-01-01':'2000-01-02' along the first coordinate `time`
93
96
and with 'IA' value from the second coordinate `space `.
94
97
95
98
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
97
100
indexing with boolean arrays. Like pandas, label based indexing in xarray is
98
101
*inclusive * of both the start and stop bounds.
99
102
@@ -113,32 +116,33 @@ Indexing with dimension names
113
116
With the dimension names, we do not have to rely on dimension order and can
114
117
use them explicitly to slice data. There are two ways to do this:
115
118
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 :
118
121
119
122
.. ipython :: python
120
123
121
124
# index by integer array indices
122
- da[ dict (space = 0 , time = slice (None , 2 ))]
125
+ da.isel (space = 0 , time = slice (None , 2 ))
123
126
124
127
# 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" ))
126
129
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 :
129
132
130
133
.. ipython :: python
131
134
132
135
# index by integer array indices
133
- da.isel (space = 0 , time = slice (None , 2 ))
136
+ da[ dict (space = 0 , time = slice (None , 2 ))]
134
137
135
138
# 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" ))]
137
140
138
141
The arguments to these methods can be any objects that could index the array
139
142
along the dimension given by the keyword, e.g., labels for an individual value,
140
143
Python :py:class: `slice ` objects or 1-dimensional arrays.
141
144
145
+
142
146
.. note ::
143
147
144
148
We would love to be able to do indexing with labeled dimension names inside
0 commit comments