# xarray.Dataset.argmin

#### Dataset.argmin(dim=None, \*\*kwargs)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/dataset.py#L9613-L9714)

Return the 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 minimum over
    all dimensions - for now returning an int for backward compatibility, but
    this is deprecated, in future will be an error, since DataArray.argmin will
    return a dict with indices for all dimensions, which does not make sense for
    a Dataset.
  * **keep_attrs** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – If True, the attributes (attrs) will be copied from the original
    object to the new one.  If False (default), the new object will be
    returned without attributes.
  * **skipna** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – If True, skip missing values (as marked by NaN). By default, only
    skips missing values for float dtypes; other dtypes either do not
    have a sentinel missing value (int) or skipna=True has not been
    implemented (object, datetime64 or timedelta64).
* **Returns:**
  **result** ([`Dataset`](xarray.Dataset.html.md#xarray.Dataset))

#### SEE ALSO
[`Dataset.idxmin`](xarray.Dataset.idxmin.html.md#xarray.Dataset.idxmin), [`DataArray.argmin`](xarray.DataArray.argmin.html.md#xarray.DataArray.argmin)

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('5f5460c5-8779-4a3d-b8ed-5abf0801243e','ac9d4a66-0edc-45cf-b854-07dc24f0901a','487d4987-2896-4785-8fb4-af19f46f18af','../lite/tree/../notebooks/index.html?path=df2b0aa4_6e89_44a3_a980_e20a0b7e1d9d.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> dataset = xr.Dataset(
...     {
...         "math_scores": (
...             ["student", "test"],
...             [[90, 85, 79], [78, 80, 85], [95, 92, 98]],
...         ),
...         "english_scores": (
...             ["student", "test"],
...             [[88, 90, 92], [75, 82, 79], [39, 96, 78]],
...         ),
...     },
...     coords={
...         "student": ["Alice", "Bob", "Charlie"],
...         "test": ["Test 1", "Test 2", "Test 3"],
...     },
... )
```

# Indices of the minimum values along the ‘student’ dimension are calculated

```pycon
>>> argmin_indices = dataset.argmin(dim="student")
```

```pycon
>>> min_score_in_math = dataset["student"].isel(
...     student=argmin_indices["math_scores"]
... )
>>> min_score_in_math
<xarray.DataArray 'student' (test: 3)> Size: 84B
array(['Bob', 'Bob', 'Alice'], dtype='<U7')
Coordinates:
  * test     (test) <U6 72B 'Test 1' 'Test 2' 'Test 3'
    student  (test) <U7 84B 'Bob' 'Bob' 'Alice'
```

```pycon
>>> min_score_in_english = dataset["student"].isel(
...     student=argmin_indices["english_scores"]
... )
>>> min_score_in_english
<xarray.DataArray 'student' (test: 3)> Size: 84B
array(['Charlie', 'Bob', 'Charlie'], dtype='<U7')
Coordinates:
  * test     (test) <U6 72B 'Test 1' 'Test 2' 'Test 3'
    student  (test) <U7 84B 'Charlie' 'Bob' 'Charlie'
```

<div id="487d4987-2896-4785-8fb4-af19f46f18af" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('5f5460c5-8779-4a3d-b8ed-5abf0801243e','487d4987-2896-4785-8fb4-af19f46f18af')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('5f5460c5-8779-4a3d-b8ed-5abf0801243e','487d4987-2896-4785-8fb4-af19f46f18af')">Open In Tab</button></div><div id="ac9d4a66-0edc-45cf-b854-07dc24f0901a" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
