# xarray.Dataset.argmax

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

Return the indices of the maxima of the member variables.

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

* **Parameters:**
  * **dim** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), *optional*) – The dimension over which to find the maximum. By default, finds maximum over
    all dimensions - for now returning an int for backward compatibility, but
    this is deprecated, in future will be an error, since DataArray.argmax 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
[`DataArray.argmax`](xarray.DataArray.argmax.html.md#xarray.DataArray.argmax)

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('b378f7bc-b2b4-4793-ba3f-99d104c7a81b','460c507d-bcb4-4dac-9cc6-da0ab3eb8c3f','598e8da6-3317-4e71-be0a-c3d18ef446c4','../lite/tree/../notebooks/index.html?path=a8123a66_dba2_4618_9768_1152b84d578c.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> dataset = xr.Dataset(
...     {
...         "math_scores": (
...             ["student", "test"],
...             [[90, 85, 92], [78, 80, 85], [95, 92, 98]],
...         ),
...         "english_scores": (
...             ["student", "test"],
...             [[88, 90, 92], [75, 82, 79], [93, 96, 91]],
...         ),
...     },
...     coords={
...         "student": ["Alice", "Bob", "Charlie"],
...         "test": ["Test 1", "Test 2", "Test 3"],
...     },
... )
```

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

```pycon
>>> argmax_indices = dataset.argmax(dim="test")
```

```pycon
>>> argmax_indices
<xarray.Dataset> Size: 132B
Dimensions:         (student: 3)
Coordinates:
  * student         (student) <U7 84B 'Alice' 'Bob' 'Charlie'
Data variables:
    math_scores     (student) int64 24B 2 2 2
    english_scores  (student) int64 24B 2 1 1
```

<div id="598e8da6-3317-4e71-be0a-c3d18ef446c4" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('b378f7bc-b2b4-4793-ba3f-99d104c7a81b','598e8da6-3317-4e71-be0a-c3d18ef446c4')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('b378f7bc-b2b4-4793-ba3f-99d104c7a81b','598e8da6-3317-4e71-be0a-c3d18ef446c4')">Open In Tab</button></div><div id="460c507d-bcb4-4dac-9cc6-da0ab3eb8c3f" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
