def combine_costs(df, func):
    """ Given df: a dataset with multiple cost values for each rollout/search,
              func: a function from series of costs to one value (perhaps e.g. "min"),
        returns a dataset with only one cost for each rollout/search. """
    return (
        df.groupby(
            [
                col
                for col in df.columns
                # we need to exclude columns that may contain nan
                if col not in ["cost", "start_cost", "best_cost", "optimality"]
            ]
        )
        .aggregate({"cost": func})
        .reset_index()
    )