AnalystPath

Course Fee per Campus

PandasEasyJunior level~10 min

Problem

A training company runs the same courses on three campuses and stores one row per (course, campus). The `coursefee` DataFrame has `course_id`, `campus` (one of `'north'`, `'central'`, `'south'`) and `fee`.

Return one row per course with a separate column for each campus fee: `course_id`, `north`, `central`, `south`. If a course is not offered on a campus, that column should be None. In any order.

Input data

Example rows — the live problem includes the full dataset.

coursefee
course_idcampusfee
1north320
1south340
1central330
2north210
2south230

Expected output

Your answer should return 2 rows with the columns course_id, north, central, south.

Starter code (Pandas (Python))

import pandas as pd

def course_fee_per_campus(coursefee: pd.DataFrame) -> pd.DataFrame:
    # Your code here
    return coursefee

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