def grouping_with_shares(df, first, other, aggs):
    """Group DataFrame by `first` and `other`, compute aggregations by multiaff
    and compute shares by group.
    """
    total = df[first].value_counts()
    out = df.groupby([first, other], as_index=False)["multiaff"].agg(aggs)
    out = out.set_index(first)
    out["total"] = total
    out["share"] = out["n"]/out["total"]*100
    return out.reset_index()