Net Payouts After Agency Fee
Problem
A freelancing platform pays contributors through agencies. Each agency charges a service fee whose rate is determined by the single largest payout inside that agency.
DataFrame `payouts` (from `payouts.csv`) has columns `agency_id`, `worker_id`, `worker_name`, and `amount` — the gross payout for that worker. `(agency_id, worker_id)` is unique.
The fee rate per agency depends on that agency's maximum amount:
- max amount below 1000 -> fee rate 0 (no fee)
- max amount from 1000 to 10000 inclusive -> fee rate 0.24
- max amount above 10000 -> fee rate 0.49
Return `agency_id`, `worker_id`, `worker_name`, and the net payout in a column named `amount`, computed as the gross amount times (1 minus the fee rate), rounded to the nearest whole number.
Input data
Example rows — the live problem includes the full dataset.
| agency_id | worker_id | worker_name | amount |
|---|---|---|---|
| 1 | 1 | Rhea | 2000 |
| 1 | 2 | Kano | 21300 |
| 1 | 3 | Vesna | 10800 |
| 2 | 1 | Dax | 300 |
| 2 | 7 | Iben | 450 |
Expected output
Your answer should return 10 rows with the columns agency_id, worker_id, worker_name, amount.
Starter code (Pandas (Python))
import pandas as pd
def net_payouts(payouts) -> pd.DataFrame:
# Your code here
return payoutsSolve 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