@@ -1076,6 +1076,19 @@ def sel(
1076
1076
"""Return a new DataArray whose data is given by selecting index
1077
1077
labels along the specified dimension(s).
1078
1078
1079
+ In contrast to `DataArray.isel`, indexers for this method should use
1080
+ labels instead of integers.
1081
+
1082
+ Under the hood, this method is powered by using pandas's powerful Index
1083
+ objects. This makes label based indexing essentially just as fast as
1084
+ using integer indexing.
1085
+
1086
+ It also means this method uses pandas's (well documented) logic for
1087
+ indexing. This means you can use string shortcuts for datetime indexes
1088
+ (e.g., '2000-01' to select all values in January 2000). It also means
1089
+ that slices are treated as inclusive of both the start and stop values,
1090
+ unlike normal Python indexing.
1091
+
1079
1092
.. warning::
1080
1093
1081
1094
Do not try to assign values when using any of the indexing methods
@@ -1088,6 +1101,45 @@ def sel(
1088
1101
Assigning values with the chained indexing using ``.sel`` or
1089
1102
``.isel`` fails silently.
1090
1103
1104
+ Parameters
1105
+ ----------
1106
+ indexers : dict, optional
1107
+ A dict with keys matching dimensions and values given
1108
+ by scalars, slices or arrays of tick labels. For dimensions with
1109
+ multi-index, the indexer may also be a dict-like object with keys
1110
+ matching index level names.
1111
+ If DataArrays are passed as indexers, xarray-style indexing will be
1112
+ carried out. See :ref:`indexing` for the details.
1113
+ One of indexers or indexers_kwargs must be provided.
1114
+ method : {None, 'nearest', 'pad'/'ffill', 'backfill'/'bfill'}, optional
1115
+ Method to use for inexact matches:
1116
+
1117
+ * None (default): only exact matches
1118
+ * pad / ffill: propagate last valid index value forward
1119
+ * backfill / bfill: propagate next valid index value backward
1120
+ * nearest: use nearest valid index value
1121
+ tolerance : optional
1122
+ Maximum distance between original and new labels for inexact
1123
+ matches. The values of the index at the matching locations must
1124
+ satisfy the equation ``abs(index[indexer] - target) <= tolerance``.
1125
+ drop : bool, optional
1126
+ If ``drop=True``, drop coordinates variables in `indexers` instead
1127
+ of making them scalar.
1128
+ **indexers_kwargs : {dim: indexer, ...}, optional
1129
+ The keyword arguments form of ``indexers``.
1130
+ One of indexers or indexers_kwargs must be provided.
1131
+
1132
+ Returns
1133
+ -------
1134
+ obj : DataArray
1135
+ A new DataArray with the same contents as this DataArray, except the
1136
+ data and each dimension is indexed by the appropriate indexers.
1137
+ If indexer DataArrays have coordinates that do not conflict with
1138
+ this object, then these coordinates will be attached.
1139
+ In general, each array's data will be a view of the array's data
1140
+ in this DataArray, unless vectorized indexing was triggered by using
1141
+ an array indexer, in which case the data will be a copy.
1142
+
1091
1143
See Also
1092
1144
--------
1093
1145
Dataset.sel
0 commit comments