AnalystPath

Mentees per Mentor

PandasEasyJunior level~10 min

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
member_idfull_namementor_idyears_experience
1Maya12
2Liam14
3Noa16
4Eli22

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 member

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