AnalystPath

Net Payouts After Agency Fee

PandasMediumMid level~10 min

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.

payouts
agency_idworker_idworker_nameamount
11Rhea2000
12Kano21300
13Vesna10800
21Dax300
27Iben450

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 payouts

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