Groupby mean doesn't display all data

Question:

I want to see all the means of the numerical columns, grouped by position, using

dfMockPos.groupby(['Position']).mean()

When I do this I only get 3 of the many columns

enter image description here

The other columns are all integers or floats, and they have no NAs.

If I do

dfMockPos['Weight'].mean()

Then I get the correct output. How can I display weight using groupby?

Thanks for any help

Asked By: aids

||

Answers:

You can try using the Aggregate function on groupby.

For example:

dfMockPos.groupby(['Position']).agg({"relative_age":'mean',
                                             "Height": 'mean',
                                             "Success_score": "mean",
                                             "Weight": "mean" })
Answered By: snakshak12
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.