Home > other >  Groupby mean doesn't display all data
Groupby mean doesn't display all data

Time:10-26

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

CodePudding user response:

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" })
  • Related