AnalystPath

Tuition Collected by Each Tutor

PandasMediumMid level~10 min

Problem

You are given three DataFrames. `Tutor` has columns `tutor_id` and `tutor_name`. `Student` has columns `student_id` and `tutor_id`. `Payment` has columns `payment_id`, `student_id`, and `amount`. Return a DataFrame with columns `tutor_id`, `tutor_name`, and `collected`, where `collected` is the sum of all payment amounts made by that tutor's students. A tutor with no students, or whose students made no payments, has a `collected` value of 0. Row order does not matter.

Input data

Example rows — the live problem includes the full dataset.

Tutor
tutor_idtutor_name
11Dana
12Omar
13Priya
Student
student_idtutor_id
10111
10211
10312
Payment
payment_idstudent_idamount
1102320
2101145
3103410
4103260

Expected output

Your answer should return 3 rows with the columns tutor_id, tutor_name, collected.

Starter code (Pandas (Python))

import pandas as pd

def tuition_per_tutor(Tutor, Student, Payment) -> pd.DataFrame:
    # Your code here
    return Tutor

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