Poll Participation Rate
Problem
A community app runs polls. `resident` lists everyone eligible to vote (`resident_id`, `resident_name`); `ballot` records which residents voted in which poll (`poll_id`, `resident_id`, together unique).\n\nFor each poll, report what share of all residents voted in it, as a value out of 100 rounded to **two decimals** and aliased `participation`. Order by `participation` descending; break ties by `poll_id` ascending.
Input data
Example rows — the live problem includes the full dataset.
| resident_id | resident_name |
|---|---|
| 6 | Noor |
| 2 | Bram |
| 7 | Kiana |
| poll_id | resident_id |
|---|---|
| 315 | 6 |
| 309 | 2 |
| 308 | 2 |
| 310 | 6 |
| 308 | 6 |
Expected output
Your answer should return 5 rows with the columns poll_id, participation.
Starter code (Pandas (Python))
import pandas as pd
def poll_participation(resident, ballot) -> pd.DataFrame:
# Your code here
return residentSolve 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