May-06-2022, 02:26 PM
Hi,
I have below df I want to calculate rank, age pos columns max, min, mean and group by Name, sub,school. I use can only calculate mean, but I want to calculate min, max at the same time.
I have below df I want to calculate rank, age pos columns max, min, mean and group by Name, sub,school. I use can only calculate mean, but I want to calculate min, max at the same time.
df.groupby(['Name','sub','school'])['rank'].mean().reset_index()
Name sub school rank age pos A Ma s1 2 10 4 A Ma s1 1 13 5 A Ma s1 4 10 6 B Soc s2 3 8 2 B Soc s2 4 6 7 A Ma s3 1 4 7 C Sci s3 2 2 1 C Sci s2 1 4 9