def aggregate_h3(dataframe, function='mean'):
    """Aggregate data values of the same h3 index in dataframe.

    :param dataframe: a pandas dataframe as returned from load_ncfile()
    :type dataframe: pandas.core.frame.DataFrame
    :param function: Aggregation function of
        the data values of the same h3 index
    :type function: str
    :return: new dataframe with the aggregated values
    :rtype: pandas.core.frame.DataFrame
    """

    if function not in ['median', 'mean']:
        raise ValueError("invalid parameter for function")

    # aggregate same indices
    return dataframe.groupby(['h3']).agg({'timestamp': 'min',
                                          'quality': 'min',
                                          'value': function})