Volunteers Who Fell Short of Their Pledge
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_id | pledged_hours |
|---|---|
| 1 | 20 |
| 2 | 12 |
| 3 | 2 |
| volunteer_id | clock_in | clock_out |
|---|---|---|
| 1 | 2023-04-01 09:00:00 | 2023-04-01 17:00:00 |
| 1 | 2023-04-06 09:05:04 | 2023-04-06 17:09:03 |
| 1 | 2023-04-12 23:00:00 | 2023-04-13 03:00:01 |
| 2 | 2023-04-29 12:00:00 | 2023-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 volunteerSolve 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