# xarray.DataArray.argmin

#### DataArray.argmin(dim=None, , axis=None, keep_attrs=None, skipna=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/dataarray.py#L6436-L6535)

Index or indices of the minimum of the DataArray over one or more dimensions.

If a sequence is passed to ‘dim’, then result returned as dict of DataArrays,
which can be passed directly to isel(). If a single str is passed to ‘dim’ then
returns a DataArray with dtype int.

If there are multiple minima, the indices of the first one found will be
returned.

* **Parameters:**
  * **dim** (`"..."`, [`str`](xarray.DataArray.str.html.md#xarray.DataArray.str), `Iterable` of `Hashable` or [`None`](https://docs.python.org/3/builtins/constants.html#None), *optional*) – The dimensions 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 return a dict with indices for all
    dimensions; to return a dict with all dimensions now, pass ‘…’.
  * **axis** ([`int`](https://docs.python.org/3/builtins/functions.html#int) or [`None`](https://docs.python.org/3/builtins/constants.html#None), *optional*) – Axis over which to apply argmin. Only one of the ‘dim’ and ‘axis’ arguments
    can be supplied.
  * **keep_attrs** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool) or [`None`](https://docs.python.org/3/builtins/constants.html#None), *optional*) – If True, the attributes (attrs) will be copied from the original
    object to the new one. If False, the new object will be
    returned without attributes.
  * **skipna** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool) or [`None`](https://docs.python.org/3/builtins/constants.html#None), *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** ([`DataArray`](xarray.DataArray.html.md#xarray.DataArray) or [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict) of [`DataArray`](xarray.DataArray.html.md#xarray.DataArray))

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

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('dc374d74-5376-4267-b969-8fdb740aebc7','0da708e1-577a-4cb2-9848-fa9fddf52130','bec3c00e-9957-417e-a19d-6757a6852ca3','../lite/tree/../notebooks/index.html?path=1b582816_8790_490d_8bfd_7b380d535983.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> array = xr.DataArray([0, 2, -1, 3], dims="x")
>>> array.min()
<xarray.DataArray ()> Size: 8B
array(-1)
>>> array.argmin(...)
{'x': <xarray.DataArray ()> Size: 8B
array(2)}
>>> array.isel(array.argmin(...))
<xarray.DataArray ()> Size: 8B
array(-1)
```

```pycon
>>> array = xr.DataArray(
...     [[[3, 2, 1], [3, 1, 2], [2, 1, 3]], [[1, 3, 2], [2, -5, 1], [2, 3, 1]]],
...     dims=("x", "y", "z"),
... )
>>> array.min(dim="x")
<xarray.DataArray (y: 3, z: 3)> Size: 72B
array([[ 1,  2,  1],
       [ 2, -5,  1],
       [ 2,  1,  1]])
Dimensions without coordinates: y, z
>>> array.argmin(dim="x")
<xarray.DataArray (y: 3, z: 3)> Size: 72B
array([[1, 0, 0],
       [1, 1, 1],
       [0, 0, 1]])
Dimensions without coordinates: y, z
>>> array.argmin(dim=["x"])
{'x': <xarray.DataArray (y: 3, z: 3)> Size: 72B
array([[1, 0, 0],
       [1, 1, 1],
       [0, 0, 1]])
Dimensions without coordinates: y, z}
>>> array.min(dim=("x", "z"))
<xarray.DataArray (y: 3)> Size: 24B
array([ 1, -5,  1])
Dimensions without coordinates: y
>>> array.argmin(dim=["x", "z"])
{'x': <xarray.DataArray (y: 3)> Size: 24B
array([0, 1, 0])
Dimensions without coordinates: y, 'z': <xarray.DataArray (y: 3)> Size: 24B
array([2, 1, 1])
Dimensions without coordinates: y}
>>> array.isel(array.argmin(dim=["x", "z"]))
<xarray.DataArray (y: 3)> Size: 24B
array([ 1, -5,  1])
Dimensions without coordinates: y
```

<div id="bec3c00e-9957-417e-a19d-6757a6852ca3" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('dc374d74-5376-4267-b969-8fdb740aebc7','bec3c00e-9957-417e-a19d-6757a6852ca3')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('dc374d74-5376-4267-b969-8fdb740aebc7','bec3c00e-9957-417e-a19d-6757a6852ca3')">Open In Tab</button></div><div id="0da708e1-577a-4cb2-9848-fa9fddf52130" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
