# xarray.Dataset.integrate

#### Dataset.integrate(coord, datetime_unit=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/dataset.py#L8683-L8744)

Integrate along the given coordinate using the trapezoidal rule.

#### NOTE
This feature is limited to simple cartesian geometry, i.e. coord
must be one dimensional.

* **Parameters:**
  * **coord** ([hashable](../user-guide/terminology.html.md#term-name), or [sequence](https://docs.python.org/3/glossary.html#term-sequence) of [hashable](../user-guide/terminology.html.md#term-name)) – Coordinate(s) used for the integration.
  * **datetime_unit** (`{'W', 'D', 'h', 'm', 's', 'ms', 'us', 'ns', 'ps', 'fs', 'as', None}`, *optional*) – Specify the unit if datetime coordinate is used.
* **Returns:**
  **integrated** ([`Dataset`](xarray.Dataset.html.md#xarray.Dataset))

#### SEE ALSO
[`DataArray.integrate`](xarray.DataArray.integrate.html.md#xarray.DataArray.integrate)

`numpy.trapz`
: corresponding numpy function

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('d3ed10a2-d3b3-4bec-877c-a0cfa74ddd3b','75c6c3ff-9368-4070-b6b6-ff16b607c3b8','f420eab6-0018-4954-a7cc-506a63ea6419','../lite/tree/../notebooks/index.html?path=455f9953_7b35_4ee8_b885_c0d128ec019e.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> ds = xr.Dataset(
...     data_vars={"a": ("x", [5, 5, 6, 6]), "b": ("x", [1, 2, 1, 0])},
...     coords={"x": [0, 1, 2, 3], "y": ("x", [1, 7, 3, 5])},
... )
>>> ds
<xarray.Dataset> Size: 128B
Dimensions:  (x: 4)
Coordinates:
  * x        (x) int64 32B 0 1 2 3
    y        (x) int64 32B 1 7 3 5
Data variables:
    a        (x) int64 32B 5 5 6 6
    b        (x) int64 32B 1 2 1 0
>>> ds.integrate("x")
<xarray.Dataset> Size: 16B
Dimensions:  ()
Data variables:
    a        float64 8B 16.5
    b        float64 8B 3.5
>>> ds.integrate("y")
<xarray.Dataset> Size: 16B
Dimensions:  ()
Data variables:
    a        float64 8B 20.0
    b        float64 8B 4.0
```

<div id="f420eab6-0018-4954-a7cc-506a63ea6419" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('d3ed10a2-d3b3-4bec-877c-a0cfa74ddd3b','f420eab6-0018-4954-a7cc-506a63ea6419')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('d3ed10a2-d3b3-4bec-877c-a0cfa74ddd3b','f420eab6-0018-4954-a7cc-506a63ea6419')">Open In Tab</button></div><div id="75c6c3ff-9368-4070-b6b6-ff16b607c3b8" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
