Coffee Cupping Leaderboard
Problem
At a coffee cupping event, each sample receives a quality grade in `points` (two decimals).
**DataFrame: `cupping_results`**
| Column | Type |
|-----------|---------|
| sample_id | int |
| points | decimal |
`sample_id` is unique.
Add a column `placing` that ranks the samples by these rules:
- More `points` → better placing (placing 1 is best).
- Samples with equal `points` share the same placing.
- Placings are consecutive with **no gaps**: after a tie, the next placing is the next whole number.
Return `points` and `placing`, ordered by `points` descending.
Input data
Example rows — the live problem includes the full dataset.
| sample_id | points |
|---|---|
| 1 | 87.5 |
| 2 | 88.25 |
| 3 | 91.0 |
| 4 | 89.75 |
| 5 | 91.0 |
Expected output
Your answer should return 6 rows with the columns points, placing.
Starter code (Pandas (Python))
import pandas as pd
def cupping_leaderboard(cupping_results) -> pd.DataFrame:
# Your code here
return cupping_resultsSolve 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