Players Not Recruited by Coach #4
Problem
DataFrame: `player` (`player.csv`)
```text
+--------------+--------+
| Column | Type |
+--------------+--------+
| player_id | int |
| player_name | object |
| recruiter_id | float |
+--------------+--------+
player_id uniquely identifies each player. recruiter_id holds the player_id of whoever recruited this player, or is empty (NaN) when the player joined on their own.
```
Return the `player_name` of every player who is **either** recruited by someone whose id is **not** `4`, **or** was not recruited by anyone at all (a missing recruiter). Return the rows in any order.
**Example**
Input — `player`:
```text
player_id player_name recruiter_id
1 Mira NaN
4 Sol NaN
2 Ravi 4.0
3 Toni 1.0
5 Uri 4.0
```
Output:
```text
player_name
Mira
Sol
Toni
```
Ravi and Uri were recruited by player 4, so they are excluded.
Input data
Example rows — the live problem includes the full dataset.
| player_id | player_name | recruiter_id |
|---|---|---|
| 1 | Mira | |
| 4 | Sol | |
| 2 | Ravi | 4 |
| 3 | Toni | 1 |
| 5 | Uri | 4 |
Expected output
Your answer should return 3 rows with the columns player_name.
Starter code (Pandas (Python))
import pandas as pd
def players_not_recruited_by_four(player: pd.DataFrame) -> pd.DataFrame:
# Your code here
return playerSolve 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