AnalystPath

Count Workshops per Room and Track

PandasMediumMid level~10 min

Problem

You are given a DataFrame `workshops` with columns `workshop_id`, `room`, and `track`. `workshop_id` uniquely identifies each workshop. `room` is one of `'North'`, `'South'`, `'East'`, and `track` is one of `'Design'`, `'Coding'`, `'Data'`.

Report how many workshops ran for every combination of room and track. You must include all nine `(room, track)` combinations even when no workshop used that pairing, reporting a count of `0` for it. Return columns `room`, `track`, and `num_workshops` in any order.

Input data

Example rows — the live problem includes the full dataset.

workshops
workshop_idroomtrack
1NorthDesign
2NorthDesign
3SouthCoding
4EastData

Expected output

Your answer should return 9 rows with the columns room, track, num_workshops.

Starter code (Pandas (Python))

import pandas as pd

def count_workshops_per_room_and_track(workshops) -> pd.DataFrame:
    # Your code here
    return workshops

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