Volunteer Appreciation Reward
Problem
You are given a DataFrame `volunteers` loaded from `volunteers.csv`:
```text
+--------------+---------+
| Column | Type |
+--------------+---------+
| volunteer_id | int |
| full_name | varchar |
| base_hours | int |
+--------------+---------+
volunteer_id is the primary key. Each row holds a volunteer's id, name, and the hours they logged this term.
```
A charity runs a quirky appreciation lottery. A volunteer earns a reward equal to `100%` of their `base_hours` **only if** their `volunteer_id` is an **odd** number **and** their `full_name` does **not** start with the letter `'T'`. Otherwise their reward is `0`.
Return a DataFrame with columns `volunteer_id` and `reward`, ordered by `volunteer_id` ascending.
Input data
Example rows — the live problem includes the full dataset.
| volunteer_id | full_name | base_hours |
|---|---|---|
| 2 | Tamar | 30 |
| 3 | Tobias | 38 |
| 7 | Aria | 74 |
| 8 | Diego | 61 |
| 9 | Noa | 77 |
Expected output
Your answer should return 5 rows with the columns volunteer_id, reward.
Starter code (Pandas (Python))
import pandas as pd
def volunteer_appreciation_reward(volunteers) -> pd.DataFrame:
# Your code here
return volunteersSolve 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