# xarray.DataArray.differentiate

`DataArray.``differentiate`(coord: Hashable, edge_order: int = 1, datetime_unit: str = None) → xarray.core.dataarray.DataArray

  Differentiate the array with the second order accurate central differences.

  Note

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

  Parameters:

  - coord (hashable) – The coordinate to be used to compute the gradient.
  - edge_order (1 or 2. Default 1) – N-th order accurate differences at the boundaries.
  - datetime_unit (None or any of {'Y', 'M', 'W', 'D', 'h', 'm', 's', 'ms',) – ‘us’, ‘ns’, ‘ps’, ‘fs’, ‘as’} Unit to compute gradient. Only valid for datetime coordinate.

  Returns: | differentiated
  Return type: | DataArray

  See also

  `numpy.gradient()`
    corresponding numpy function

  Examples

      >>> da = xr.DataArray(np.arange(12).reshape(4, 3), dims=['x', 'y'],
      ...                   coords={'x': [0, 0.1, 1.1, 1.2]})
      >>> da
      <xarray.DataArray (x: 4, y: 3)>
      array([[ 0,  1,  2],
             [ 3,  4,  5],
             [ 6,  7,  8],
             [ 9, 10, 11]])
      Coordinates:
        * x        (x) float64 0.0 0.1 1.1 1.2
      Dimensions without coordinates: y
      >>>
      >>> da.differentiate('x')
      <xarray.DataArray (x: 4, y: 3)>
      array([[30.      , 30.      , 30.      ],
             [27.545455, 27.545455, 27.545455],
             [27.545455, 27.545455, 27.545455],
             [30.      , 30.      , 30.      ]])
      Coordinates:
        * x        (x) float64 0.0 0.1 1.1 1.2
      Dimensions without coordinates: y