I have the following dataframe
medal number Age
Gold 5 25
Silver 4 30
Bronze 3 45
Gold 1 23
Silver 2 12
Bronze 3 16
And, I am trying to groupby on medal and get sum of 'number' and mean of 'Age'. I can do it in two lines but how to do it single line with pandas groupby.
I can do 1 operation at a time with
df.groupby(['medal'])['Age'].mean()
or
df.groupby(['medal'])['number'].sum()
And then merge maybe, Which is a long process. So how to achieve it in pandas way
Below is the desired output
medal number Age
Bronze 6 30.5
Gold 6 24.0
Silver 6 21.0