AnalystPath

Volunteers Who Fell Short of Their Pledge

PandasMediumMid level~10 min

Problem

You are given two DataFrames. `volunteer` (from `volunteer.csv`) has columns `volunteer_id` and `pledged_hours` (the hours each volunteer promised). `shift` (from `shift.csv`) has columns `volunteer_id`, `clock_in`, and `clock_out` (datetime strings) recording each shift worked.

For every shift, round its duration up to the nearest whole minute. A volunteer falls short if their total worked minutes (0 if they never showed up) is strictly less than `pledged_hours * 60`. Return the `volunteer_id` of every volunteer who fell short. Order does not matter.

Input data

Example rows — the live problem includes the full dataset.

volunteer
volunteer_idpledged_hours
120
212
32
shift
volunteer_idclock_inclock_out
12023-04-01 09:00:002023-04-01 17:00:00
12023-04-06 09:05:042023-04-06 17:09:03
12023-04-12 23:00:002023-04-13 03:00:01
22023-04-29 12:00:002023-04-29 23:58:58

Expected output

Your answer should return 2 rows with the columns volunteer_id.

Starter code (Pandas (Python))

import pandas as pd

def volunteers_who_fell_short_of_their_pledge(volunteer, shift) -> pd.DataFrame:
    # Your code here
    return volunteer

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