df.groupby('A').transform(lambda x: x.sum())
df.groupby('A').transform(lambda x: len(x))
df.groupby('A').transform(lambda x: x.sum() / len(x))
pandas groupby transform behaving differently with seemingly equivalent representations