krishnaik06 / mlproject

452 stars 583 forks source link

groupby('gender').mean() is not working #30

Open rahulpinto19 opened 2 months ago

rahulpinto19 commented 2 months ago

I have gone through this error as the gender is not a number we are unable to find out the mean we can solve this by converting it into the number

Screenshot 2024-08-29 232035

Screenshot 2024-08-29 231920

image

Thakarepradnyan commented 1 month ago

try with this to handle non numeric columns separately to keep non numeric columns perform aggregation differently.

gender_group = df.groupby('gender').agg({
    'math_score': 'mean',  #replace by column names
    'reading_score': 'mean',
    'writing_score': 'mean'  # change to 'count', or other suitable aggregations
})
print(gender_group)