def _update_aggregate_dataset(self, formula, new_dframe, name, groups, agg_dataset): """Update the aggregated dataset built for `self` with `calculation`. Proceed with the following steps: - delete the rows in this dataset from the parent - recalculate aggregated dataframe from aggregation - update aggregated dataset with new dataframe and add parent id - recur on all merged datasets descending from the aggregated dataset :param formula: The formula to execute. :param new_dframe: The DataFrame to aggregate on. :param name: The name of the aggregation. :param groups: A column or columns to group on. :type group: String, list of strings, or None. :param agg_dataset: The DataSet to store the aggregation in. """ # parse aggregation and build column arguments aggregation, new_columns = self.make_columns( formula, name, new_dframe) agg = Aggregator(self.dataset, self.dframe, groups, aggregation, name) new_agg_dframe = agg.update(agg_dataset, self, formula, new_columns) # jsondict from new dframe new_data = new_agg_dframe.to_jsondict() for merged_dataset in agg_dataset.merged_datasets: # remove rows in child from this merged dataset merged_dataset.remove_parent_observations( agg_dataset.dataset_id) # calculate updates on the child merged_calculator = Calculator(merged_dataset) call_async(merged_calculator.calculate_updates, merged_calculator, new_data, parent_dataset_id=agg_dataset.dataset_id)