AnalystPath

Players Whose Coach Left the Roster

PandasEasyJunior level~10 min

Problem

You are given one DataFrame `roster`:

| Column | Type |
|-----------|------|
| player_id | int |
| full_name | str |
| coach_id | int |
| stipend | int |

`player_id` is unique. Each row gives a player, their monthly stipend, and the `player_id` of their coach (a coach is also listed as a player). Some players have no coach (`coach_id` is NaN).

Return the `player_id` of every player whose stipend is strictly below `2000` **and** whose coach is no longer on the roster. A coach is no longer on the roster when their id does not appear as any `player_id`.

Order the result by `player_id` ascending.

Input data

Example rows — the live problem includes the full dataset.

roster
player_idfull_namecoach_idstipend
1Ana5000
2Beto11500
3Cleo91200
4Dario92500
5Eli8800

Expected output

Your answer should return 2 rows with the columns player_id.

Starter code (Pandas (Python))

import pandas as pd

def coach_left_the_roster(roster) -> pd.DataFrame:
    # Your code here
    return roster

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