def group_dataframe(df):
    """A function that groups the dataframe by Year, Month, Transaction Type,
    Root Category, Subroot Category, and takes the sum of the Amounts"""
    # Category -> Year -> Month -> Transaction Type -> Root Cat -> Sub Cat
    return df.groupby([
        (df.index.year.rename('Year')),
        (df.index.month.rename('Month')),
        'transaction_type', 'root_cat', 'sub_cat']).sum()