Festival Category Wins
Problem
A film festival hands out four awards each year. A `director` DataFrame has `director_id` and `director` (the name). An `awardyear` DataFrame has `edition` plus four columns `best_picture`, `best_drama`, `best_comedy`, `best_short`, each holding the `director_id` who won that award that edition.
Return how many festival awards each director has won (`director_id`, `director`, `total_wins`). Exclude directors who never won anything. In any order.
Input data
Example rows — the live problem includes the full dataset.
| director_id | director |
|---|---|
| 1 | Vega |
| 2 | Romano |
| 3 | Okafor |
| edition | best_picture | best_drama | best_comedy | best_short |
|---|---|---|---|---|
| 2018 | 1 | 1 | 1 | 1 |
| 2019 | 1 | 1 | 2 | 2 |
| 2020 | 2 | 1 | 2 | 2 |
Expected output
Your answer should return 2 rows with the columns director_id, director, total_wins.
Starter code (Pandas (Python))
import pandas as pd
def festival_wins(director: pd.DataFrame, awardyear: pd.DataFrame) -> pd.DataFrame:
# Your code here
return directorSolve 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