def analysis_aggcols(
    df, variation="lhePdfWeight", nominal="sum_w_{}", variance="sum_ww_{}",
    aggs=["std"], evals=[
        "sum_w_lhePdfWeightUp = sum_w + agg_std",
        "sum_w_lhePdfWeightDown = sum_w - agg_std",
        "sum_ww_lhePdfWeightUp = sum_ww * (1 + agg_std/sum_w)**2",
        "sum_ww_lhePdfWeightDown = sum_ww * (1 - agg_std/sum_w)**2",
    ], copy=True,
):
    """
    Aggregate across a set of columns and apply some function

    Parameters
    ----------
    df : DataFrame-like
        Dataframe input to process

    variation : str (default, "lhePdfWeight")
        Variation which appears in the columns

    nominal : str (default, "sum_w_{}")
        How the nominal weight column is defined

    variance: str (default, "sum_ww_{}")
        How the variance weight column is defined

    aggs : list (default, ["std"])
        List of aggregation functions to apply. Will add columns for these

    evals : list (default, [...])
        List of evals to generate new columns

    copy : bool (default, True)
        Copy the input dataframe
    """
    columns = [c for c in df.columns if nominal.format(variation) in c]

    tdf = df.copy(deep=True) if copy else df
    for agg in aggs:
        tdf["agg_{}".format(agg)] = tdf.loc[:, columns].agg(agg, axis=1)

    columns.extend([c for c in tdf.columns if variance.format(variation) in c])
    tdf = tdf.drop(columns, axis=1)

    tdf.eval("\n".join(evals), inplace=True)
    return tdf.drop(["agg_{}".format(agg) for agg in aggs], axis=1)