AnalystPath

Festival Category Wins

PandasMediumMid level~10 min

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
director_iddirector
1Vega
2Romano
3Okafor
awardyear
editionbest_picturebest_dramabest_comedybest_short
20181111
20191122
20202122

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 director

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