I want to see all the means of the numerical columns, grouped by position, using
JavaScript
x
2
1
dfMockPos.groupby(['Position']).mean()
2
When I do this I only get 3 of the many columns
The other columns are all integers or floats, and they have no NAs.
If I do
JavaScript
1
2
1
dfMockPos['Weight'].mean()
2
Then I get the correct output. How can I display weight using groupby?
Thanks for any help
Advertisement
Answer
You can try using the Aggregate function on groupby.
For example:
JavaScript
1
5
1
dfMockPos.groupby(['Position']).agg({"relative_age":'mean',
2
"Height": 'mean',
3
"Success_score": "mean",
4
"Weight": "mean" })
5