Saturday Donation Totals
Problem
You are given a DataFrame `donations` with columns `donor_id`, `gift_date`, and `amount`. Each row is one gift to a community food bank.
Report the total amount donated on each **Saturday in March 2024**. For each such Saturday that had at least one donation, output `week_of_month`, `gift_date`, and `total_gift`, where `week_of_month` is which Saturday of the month it is (1 for the first week, 2 for the second, and so on). Order the output by `week_of_month` ascending.
Input data
Example rows — the live problem includes the full dataset.
| donor_id | gift_date | amount |
|---|---|---|
| 1 | 2024-03-02 | 50 |
| 2 | 2024-03-02 | 70 |
| 3 | 2024-03-05 | 999 |
| 4 | 2024-03-16 | 200 |
| 5 | 2024-03-16 | 30 |
Expected output
Your answer should return 3 rows with the columns week_of_month, gift_date, total_gift.
Starter code (Pandas (Python))
import pandas as pd
def saturday_donation_totals(donations) -> pd.DataFrame:
# Your code here
return donationsSolve 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