Percentile Standing of Each Runner
Problem
You are given a DataFrame `runners` with columns `runner_id`, `bracket_id`, and `score`. Within each bracket, compute each runner's percentile standing using the formula `(rank - 1) * 100 / (total_runners - 1)`, where `rank` is the position by descending score (ties share the same lower rank) and `total_runners` is the number of runners in the bracket. If a bracket has only one runner, the standing is 0. Round the standing to 2 decimals. Return columns `runner_id`, `bracket_id`, and `standing`. Row order does not matter.
Input data
Example rows — the live problem includes the full dataset.
| runner_id | bracket_id | score |
|---|---|---|
| 2 | 2 | 650 |
| 8 | 2 | 650 |
| 7 | 1 | 920 |
| 1 | 1 | 610 |
| 3 | 1 | 530 |
Expected output
Your answer should return 5 rows with the columns runner_id, bracket_id, standing.
Starter code (Pandas (Python))
import pandas as pd
def percentile_standing(runners) -> pd.DataFrame:
# Your code here
return runnersSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock