Pandas dataframe: how to apply describe() to each group and add to new columns?

there is even a shorter one 🙂

print df.groupby('name').describe().unstack(1)

Nothing beats one-liner:

In [145]:

print df.groupby(‘name’).describe().reset_index().pivot(index=’name’,
values=”score”, columns=”level_1″)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)