def get_ymean(data):
    """
    First we group all values by year average them.

    Parameters
    ----------
    data: xarray.DataArray or xarray.Dataset
        Input must have a `time` coordinate and must be an xarray
        object.

    Returns
    -------
    xarray.DataArray or xarray.Dataset which contains as many time
    step as there are years in data. We do not keep actual dates in
    the time index.
    """  # noqa

    # compute mean grouping by year
    ygr = data.groupby('time.year')
    ymean = ygr.mean(dim='time', keep_attrs=True)

    # rename month coordinate to time for compatibility
    ymean = ymean.rename({'year': 'time'})

    return ymean