Practice / reshaping

Status Breakdown Grid

hard

A support lead wants a status dashboard: one row per team, with counts of open and closed tickets.

tickets

Your task: produce one row per team with an open and a closed column counting tickets in each status. If a team has none of a status, that cell must be 0, not null.

Assign your answer DataFrame to result. Row order doesn't matter.

ticketsinput DataFrame

Schema
columntype
ticket_idlong
teamstring
statusstring
Sample rows
ticket_idteamstatus
1Billingopen
2Billingopen
3Billingclosed
4Salesclosed
Expected output shape
teamopenclosed· 2 rows
Hint

groupBy("team").pivot("status", ["open", "closed"]).agg(F.count("*")) builds the grid; a team missing a status gets a null cell, so finish with .fillna(0, subset=["open", "closed"]).

Lesson refresher

This problem builds on Reshaping Data (~7 min). Pop it open in a new tab if you want a quick recap.

Loading editor…
Hit Run to execute your code and see the output here.