Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -2995,7 +2995,7 @@ def integrate(
""" integrate the array with the trapezoidal rule.

.. note::
This feature is limited to simple cartesian geometry, i.e. coord
This feature is limited to simple cartesian geometry, i.e. dim
must be one dimensional.

Parameters
Expand Down
21 changes: 20 additions & 1 deletion xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5165,7 +5165,7 @@ def integrate(self, coord, datetime_unit=None):

Parameters
----------
dim: str, or a sequence of str
coord: str, or a sequence of str
Coordinate(s) used for the integration.
datetime_unit
Can be specify the unit if datetime coordinate is used. One of
Expand All @@ -5180,6 +5180,25 @@ def integrate(self, coord, datetime_unit=None):
--------
DataArray.integrate
numpy.trapz: corresponding numpy function

Examples
--------
>>> 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", [10, 11, 12, 13])},
... )
>>> ds.integrate("x")
<xarray.Dataset>
Dimensions: ()
Data variables:
a float64 19.5
b float64 3.5
>>> ds.integrate("y")
<xarray.Dataset>
Dimensions: ()
Data variables:
a float64 19.5
b float64 3.5
Comment thread
keewis marked this conversation as resolved.
Outdated
"""
if not isinstance(coord, (list, tuple)):
coord = (coord,)
Expand Down