Drop index positions from this Dataset. Parameters ---------- indexers : mapping of hashable to Any Index locations to drop **indexers_kwargs : {dim: position, ...}, optional The keyword arguments form of ``dim`` and ``positions`` Ret
(self, indexers=None, **indexers_kwargs)
| 6137 | return ds |
| 6138 | |
| 6139 | def drop_isel(self, indexers=None, **indexers_kwargs) -> Self: |
| 6140 | """Drop index positions from this Dataset. |
| 6141 | |
| 6142 | Parameters |
| 6143 | ---------- |
| 6144 | indexers : mapping of hashable to Any |
| 6145 | Index locations to drop |
| 6146 | **indexers_kwargs : {dim: position, ...}, optional |
| 6147 | The keyword arguments form of ``dim`` and ``positions`` |
| 6148 | |
| 6149 | Returns |
| 6150 | ------- |
| 6151 | dropped : Dataset |
| 6152 | |
| 6153 | Raises |
| 6154 | ------ |
| 6155 | IndexError |
| 6156 | |
| 6157 | Examples |
| 6158 | -------- |
| 6159 | >>> data = np.arange(6).reshape(2, 3) |
| 6160 | >>> labels = ["a", "b", "c"] |
| 6161 | >>> ds = xr.Dataset({"A": (["x", "y"], data), "y": labels}) |
| 6162 | >>> ds |
| 6163 | <xarray.Dataset> Size: 60B |
| 6164 | Dimensions: (x: 2, y: 3) |
| 6165 | Coordinates: |
| 6166 | * y (y) <U1 12B 'a' 'b' 'c' |
| 6167 | Dimensions without coordinates: x |
| 6168 | Data variables: |
| 6169 | A (x, y) int64 48B 0 1 2 3 4 5 |
| 6170 | >>> ds.drop_isel(y=[0, 2]) |
| 6171 | <xarray.Dataset> Size: 20B |
| 6172 | Dimensions: (x: 2, y: 1) |
| 6173 | Coordinates: |
| 6174 | * y (y) <U1 4B 'b' |
| 6175 | Dimensions without coordinates: x |
| 6176 | Data variables: |
| 6177 | A (x, y) int64 16B 1 4 |
| 6178 | >>> ds.drop_isel(y=1) |
| 6179 | <xarray.Dataset> Size: 40B |
| 6180 | Dimensions: (x: 2, y: 2) |
| 6181 | Coordinates: |
| 6182 | * y (y) <U1 8B 'a' 'c' |
| 6183 | Dimensions without coordinates: x |
| 6184 | Data variables: |
| 6185 | A (x, y) int64 32B 0 2 3 5 |
| 6186 | """ |
| 6187 | |
| 6188 | indexers = either_dict_or_kwargs(indexers, indexers_kwargs, "drop_isel") |
| 6189 | |
| 6190 | ds = self |
| 6191 | dimension_index = {} |
| 6192 | for dim, pos_for_dim in indexers.items(): |
| 6193 | # Don't cast to set, as it would harm performance when labels |
| 6194 | # is a large numpy array |
| 6195 | if utils.is_scalar(pos_for_dim): |
| 6196 | pos_for_dim = [pos_for_dim] |