0 votes
in Python Flask by

Write a function named grades_colors to select only the rows where the student’s favorite color is green or red and their grade is above 90.

1 Answer

0 votes
by

This question requires us to filter a data frame by two conditions: first, the grade of the student, and second, their favorite color.

Start by filtering by grade since it’s a bit simpler than filtering by strings. We can filter columns in pandas by setting our data frame equal to itself with the filter in place.

In this case:

df_students = df_students[df_students["grade"] > 90]

Related questions

0 votes
asked Apr 27, 2020 in HTML by AdilsonLima
+1 vote
asked Oct 28, 2022 in Python by SakshiSharma
...