AnalystPath

Volunteer Appreciation Reward

PandasEasyJunior level~10 min

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.

volunteers
volunteer_idfull_namebase_hours
2Tamar30
3Tobias38
7Aria74
8Diego61
9Noa77

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 volunteers

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