create new column use transform: get the count of distributor_id for each seg
df.groupby(["seg_met"]).distributorid.transform("count")
just to get the counts use:
df['distributorid'].groupby([df.seg_met]).agg(['count'])
#these do the same thing!
pred_table.groupby('seg_met')['predicted_sales'].sum()
pred_table['predicted_sales'].groupby(pred_table.seg_met).sum()
# produces Pandas Series
data.groupby('month')['duration'].sum()
# Produces Pandas DataFrame
data.groupby('month')[['duration']].sum()