code: def levels_for(self, time_op, groups, df):
          
          levels = {}
          for i in range(0, len(groups) + 1):
              agg_df = df.groupby(groups[:i]) if i else df
              levels[i] = (
                  agg_df.mean() if time_op == 'agg_mean'
                  else agg_df.sum(numeric_only=True))
          return levels
docs: Compute the partition at each `level` from the dataframe.