AnalystPath

Poll Participation Rate

PandasEasyJunior level~10 min

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
resident_idresident_name
6Noor
2Bram
7Kiana
ballot
poll_idresident_id
3156
3092
3082
3106
3086

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 resident

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