Interview Query

Bucket Test Scores

10
Have you seen this question before?

Let’s say you’re given a dataframe of standardized test scores from high schoolers from grades 9 to 12 called df_grades.

Given the dataset, write code function in Pandas called bucket_test_scores to return the cumulative percentage of students that received scores within the buckets of <50, <75, <90, <100.

Example:

Input:

print(df_grades)
user_id grade test score
1 10 85
2 10 60
3 11 90
4 10 30
5 11 99

Output:

def bucket_test_scores(df_grades) ->
grade test score percentage
10 <50 33%
10 <75 66%
10 <90 100%
10 <100 100%
11 <50 0%
11 <75 0%
11 <90 50%
11 <100 100%
Next question: Jars and Coins
.....
Python 3.9.6
Loading editor
Use Shift + Enter to run code