Interview Query

Bucket Test Scores

Start Timer

0:00:00

Upvote
27
Downvote
Save question
Mark as completed
View comments (34)
Next question

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%
.
.
.
.
.


Comments

Loading comments..