# 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('77bd19aa-f5a3-4367-9a88-c92610151260','00bc4437-da87-4a9a-8a17-b93f1ecd9870','7572a0d3-2ba4-4370-bc95-a361f6b1234a','../lite/tree/../notebooks/index.html?path=0edf1fb6_fd9d_46cc_941a_f013f4f9653a.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="7572a0d3-2ba4-4370-bc95-a361f6b1234a" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('77bd19aa-f5a3-4367-9a88-c92610151260','7572a0d3-2ba4-4370-bc95-a361f6b1234a')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('77bd19aa-f5a3-4367-9a88-c92610151260','7572a0d3-2ba4-4370-bc95-a361f6b1234a')">Open In Tab</button></div><div id="00bc4437-da87-4a9a-8a17-b93f1ecd9870" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
