Course Fee per Campus
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.
| course_id | campus | fee |
|---|---|---|
| 1 | north | 320 |
| 1 | south | 340 |
| 1 | central | 330 |
| 2 | north | 210 |
| 2 | south | 230 |
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 coursefeeSolve 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