def aggregated_dataset(dataset, dframe, groups):
    """Create an aggregated dataset for this dataset.

    Creates and saves a dataset from the given `dframe`.  Then stores this
    dataset as an aggregated dataset given `groups` for `self`.

    :param dframe: The DataFrame to store in the new aggregated dataset.
    :param groups: The groups associated with this aggregated dataset.
    :returns: The newly created aggregated dataset.
    """
    a_dataset = dataset.create()
    a_dataset.save_observations(dframe)

    # store a link to the new dataset
    group_str = dataset.join_groups(groups)
    a_datasets_dict = dataset.aggregated_datasets_dict
    a_datasets_dict[group_str] = a_dataset.dataset_id
    dataset.update({dataset.AGGREGATED_DATASETS: a_datasets_dict})

    return a_dataset