AnalystPath

Eligible Trade-In Payouts

PandasMediumMid level~10 min

Problem

DataFrame: `tradein` (`tradein.csv`)

```text
+----------+--------+--------+-------+-------+
| Column | Type | | | |
+----------+--------+--------+-------+-------+
| trade_id | int | | | |
| base_val | float | | | |
| payout | float | | | |
| east | float | | | |
| north | float | | | |
+----------+--------+--------+-------+-------+
trade_id uniquely identifies each trade-in. base_val is the appraised base value, payout is the offered payout, and (east, north) is the grid location of the drop-off depot (never missing).
```

Report the sum of `payout` over all trade-ins that satisfy **both** conditions:

- their `base_val` equals the `base_val` of at least one other trade-in, **and**
- their depot location `(east, north)` is unique — no other trade-in shares the same `(east, north)` pair.

Round the total to **two decimal places** and return it as a single column named `payout`. If no trade-in qualifies, return one row whose `payout` is `null`.

Input data

Example rows — the live problem includes the full dataset.

tradein
trade_idbase_valpayouteastnorth
11051010
220202020
310302020
410404040

Expected output

Your answer should return 1 row with the columns payout.

Starter code (Pandas (Python))

import pandas as pd

def eligible_payout(tradein: pd.DataFrame) -> pd.DataFrame:
    # Your code here
    return tradein

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