I have a DataFrame - a snapshot of which looks like this:
I am trying to grab all the math_score
and reading_score
values greater than 70 grouped by school_name
.
So my end result should look something like this:
I am trying to calculate the % of students with a passing math_score
and reading_score
which is % of scores > 70.
Any help on how I can go about this?
This is what I have tried:
school_data_grouped = school_data_complete.groupby('school_name')
passing_math_score = school_data_grouped.loc[(school_data_grouped['math_score'] >= 70)]
I get an error with this that says:
AttributeError: Cannot access callable attribute 'loc' of 'DataFrameGroupBy' objects, try using the 'apply' method
What can I do to achive this? Any help is much appreciated.
Thanks!