AnalystPath

Every Saturday's Donation Total

PandasHardSenior level~10 min

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.

Building on the Saturday donation report, now include **every Saturday in March 2024**, even the ones with no donations at all (those should show a total of 0). Output `week_of_month`, `gift_date`, and `total_gift` for all five Saturdays of March 2024, ordered by `week_of_month` ascending.

Input data

Example rows — the live problem includes the full dataset.

donations
donor_idgift_dateamount
12024-03-0250
22024-03-0270
32024-03-05999
42024-03-16200
52024-03-1630

Expected output

Your answer should return 5 rows with the columns week_of_month, gift_date, total_gift.

Starter code (Pandas (Python))

import pandas as pd

def every_saturday_donation_total(donations) -> pd.DataFrame:
    # Your code here
    return donations

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