Mentees per Mentor
Problem
A `member` DataFrame describes a coding club. Each row has `member_id`, `full_name`, `mentor_id` (the `member_id` of the person who mentors them, or NaN if none), and `years_experience`.
A **mentor** is any member who has at least one other member assigned to them. For each mentor, return their `member_id`, their `full_name`, the number of mentees they have (`mentee_count`), and the average years of experience of those mentees rounded to the nearest integer (`avg_mentee_experience`). Order the result by `member_id`.
Input data
Example rows — the live problem includes the full dataset.
| member_id | full_name | mentor_id | years_experience |
|---|---|---|---|
| 1 | Maya | 12 | |
| 2 | Liam | 1 | 4 |
| 3 | Noa | 1 | 6 |
| 4 | Eli | 2 | 2 |
Expected output
Your answer should return 2 rows with the columns member_id, full_name, mentee_count, avg_mentee_experience.
Starter code (Pandas (Python))
import pandas as pd
def mentees_per_mentor(member: pd.DataFrame) -> pd.DataFrame:
# Your code here
return memberSolve 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