Indices of the minima of the member variables. If there are multiple minima, the indices of the first one found will be returned. Parameters ---------- dim : Hashable, optional The dimension over which to find the minimum. By default, finds minim
(self, dim: Hashable | None = None, **kwargs)
| 9392 | ) |
| 9393 | |
| 9394 | def argmin(self, dim: Hashable | None = None, **kwargs) -> Self: |
| 9395 | """Indices of the minima of the member variables. |
| 9396 | |
| 9397 | If there are multiple minima, the indices of the first one found will be |
| 9398 | returned. |
| 9399 | |
| 9400 | Parameters |
| 9401 | ---------- |
| 9402 | dim : Hashable, optional |
| 9403 | The dimension over which to find the minimum. By default, finds minimum over |
| 9404 | all dimensions - for now returning an int for backward compatibility, but |
| 9405 | this is deprecated, in future will be an error, since DataArray.argmin will |
| 9406 | return a dict with indices for all dimensions, which does not make sense for |
| 9407 | a Dataset. |
| 9408 | keep_attrs : bool, optional |
| 9409 | If True, the attributes (`attrs`) will be copied from the original |
| 9410 | object to the new one. If False (default), the new object will be |
| 9411 | returned without attributes. |
| 9412 | skipna : bool, optional |
| 9413 | If True, skip missing values (as marked by NaN). By default, only |
| 9414 | skips missing values for float dtypes; other dtypes either do not |
| 9415 | have a sentinel missing value (int) or skipna=True has not been |
| 9416 | implemented (object, datetime64 or timedelta64). |
| 9417 | |
| 9418 | Returns |
| 9419 | ------- |
| 9420 | result : Dataset |
| 9421 | |
| 9422 | Examples |
| 9423 | -------- |
| 9424 | >>> dataset = xr.Dataset( |
| 9425 | ... { |
| 9426 | ... "math_scores": ( |
| 9427 | ... ["student", "test"], |
| 9428 | ... [[90, 85, 79], [78, 80, 85], [95, 92, 98]], |
| 9429 | ... ), |
| 9430 | ... "english_scores": ( |
| 9431 | ... ["student", "test"], |
| 9432 | ... [[88, 90, 92], [75, 82, 79], [39, 96, 78]], |
| 9433 | ... ), |
| 9434 | ... }, |
| 9435 | ... coords={ |
| 9436 | ... "student": ["Alice", "Bob", "Charlie"], |
| 9437 | ... "test": ["Test 1", "Test 2", "Test 3"], |
| 9438 | ... }, |
| 9439 | ... ) |
| 9440 | |
| 9441 | # Indices of the minimum values along the 'student' dimension are calculated |
| 9442 | |
| 9443 | >>> argmin_indices = dataset.argmin(dim="student") |
| 9444 | |
| 9445 | >>> min_score_in_math = dataset["student"].isel( |
| 9446 | ... student=argmin_indices["math_scores"] |
| 9447 | ... ) |
| 9448 | >>> min_score_in_math |
| 9449 | <xarray.DataArray 'student' (test: 3)> Size: 84B |
| 9450 | array(['Bob', 'Bob', 'Alice'], dtype='<U7') |
| 9451 | Coordinates: |