def kurtosis(da, dim):
    """
        Returns the kurtosis along dimension dim
        Author: Dougie Squire
        Date: 20/08/2018

        Parameters
        ----------
        da : xarray DataArray
            Array containing values for which to compute kurtosis
        dim : str or sequence of str
            Dimension(s) over which to compute the kurtosis

        Returns
        -------
        kurtosis : xarray DataArray
            New DataArray object with kurtosis applied to its data and the indicated dimension(s) removed

        Examples
        --------
        >>> arr = xr.DataArray(np.arange(6).reshape(2, 3), 
        ...                    coords=[('x', ['a', 'b']), ('y', [0, 1, 2])])
        >>> arr
        <xarray.DataArray (x: 2, y: 3)>
        array([[0, 1, 2],
               [3, 4, 5]])
        Coordinates:
          * x        (x) <U1 'a' 'b'
          * y        (y) int64 0 1 2
        >>> doppyo.utils.kurtosis(arr, 'x')
        <xarray.DataArray (y: 3)>
        array([1., 1., 1.])
        Coordinates:
          * y        (y) int64 0 1 2
    """
    daf = da - da.mean(dim)
    return ((daf ** 4).mean(dim) / (daf ** 2).mean(dim) ** 2).rename('kurtosis'
        )
