grouped.ngroup()
sc = lambda x: (x - x.mean()) / x.std()*10
grouped.transform(sc)
grouped.transform(sc)
ngroup = pd.Series(grouped.ngroup(), name= 'foo_ngroup')
cumcount = pd.Series(grouped.cumcount(), name= 'foo_cumcount')
rank = pd.Series(grouped['baz'].rank(), name= 'foo_rank')
sc = grouped.transform(sc).rename(columns=lambda x: x + '_sc')
pd.concat([df, ngroup, cumcount, rank, sc], axis=1)