AnalystPath

Coffee Cupping Leaderboard

PandasMediumMid level~10 min

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.

cupping_results
sample_idpoints
187.5
288.25
391.0
489.75
591.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_results

Solve 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

Related Pandas questions