Six months of tickets, three questions
Six months of support tickets through pivot tables, a color-ramped summary, and a rolling weekly median. The pivot and the trend disagree, which is exactly why you draw both.
Six months of tickets, three questions
This is the shape of most real Python work: a table arrives, and somebody wants to know what it says. Here it is six months of support tickets, and the three questions are who is busy, what takes longest, and whether any of it is getting better.
The tables below are what pandas itself renders. Verso asks an object how it would like to be shown and shows that, so a DataFrame arrives as a DataFrame rather than as the text of one.
1import numpy as np2import pandas as pd34TEAMS = ["Billing", "Platform", "Mobile", "Onboarding"]5PRIORITIES = ["low", "normal", "high", "urgent"]678def make_tickets(n=4200):9 """Six months of tickets, with the seasonality and skew you would expect."""10 rng = np.random.default_rng(20260726)1112 opened = pd.to_datetime("2026-01-01") + pd.to_timedelta(13 rng.integers(0, 181, n) * 24 * 60 + rng.integers(0, 24 * 60, n), unit="m"14 )15 team = rng.choice(TEAMS, n, p=[0.31, 0.27, 0.24, 0.18])16 priority = rng.choice(PRIORITIES, n, p=[0.34, 0.38, 0.20, 0.08])1718 # Urgent work gets picked up faster; Billing runs a backlog that eases off.19 base = pd.Series(priority).map(20 {"low": 34.0, "normal": 19.0, "high": 7.5, "urgent": 2.5}21 ).to_numpy()22 drag = np.where(team == "Billing", 1.0 + 0.9 * np.exp(-opened.dayofyear / 70), 1.0)23 hours = np.round(rng.gamma(2.0, base * drag / 2.0), 2)2425 return pd.DataFrame(26 {27 "opened": opened,28 "team": pd.Categorical(team, TEAMS),29 "priority": pd.Categorical(priority, PRIORITIES, ordered=True),30 "hours_to_close": hours,31 "reopened": rng.random(n) < 0.06,32 }33 ).sort_values("opened", ignore_index=True)343536tickets = make_tickets()37print(f"{len(tickets):,} tickets from {tickets.opened.min():%d %b} to {tickets.opened.max():%d %b}")38tickets.head(8)
4,200 tickets from 01 Jan to 30 Jun
| opened | team | priority | hours_to_close | reopened | |
|---|---|---|---|---|---|
| 0 | 2026-01-01 00:52:00 | Billing | normal | 12.81 | False |
| 1 | 2026-01-01 01:34:00 | Platform | normal | 5.70 | False |
| 2 | 2026-01-01 03:31:00 | Onboarding | normal | 4.26 | False |
| 3 | 2026-01-01 05:01:00 | Onboarding | normal | 13.31 | False |
| 4 | 2026-01-01 07:27:00 | Platform | normal | 39.44 | False |
| 5 | 2026-01-01 08:57:00 | Platform | low | 26.25 | False |
| 6 | 2026-01-01 09:44:00 | Mobile | normal | 3.93 | False |
| 7 | 2026-01-01 13:26:00 | Mobile | low | 7.32 | False |
Who is busy, and what takes longest
One pivot_table answers both. Median hours to close, split by the team that
owned the ticket and how urgent it was, with a color ramp so the shape is
visible before the numbers are.
1frame = make_tickets()23pivot = frame.pivot_table(4 index="team",5 columns="priority",6 values="hours_to_close",7 aggfunc="median",8 observed=True,9)10counts = frame.groupby("team", observed=True).size().rename("tickets")1112report = pivot.join(counts)13report.style.background_gradient(cmap="YlOrRd", subset=PRIORITIES, axis=None).format(14 {**{p: "{:.1f} h" for p in PRIORITIES}, "tickets": "{:,}"}15).set_caption("median hours to close")
| low | normal | high | urgent | tickets | |
|---|---|---|---|---|---|
| team | |||||
| Billing | 37.7 h | 20.2 h | 8.4 h | 2.5 h | 1,318 |
| Platform | 28.9 h | 16.5 h | 6.8 h | 2.2 h | 1,125 |
| Mobile | 25.7 h | 16.5 h | 6.3 h | 1.9 h | 1,022 |
| Onboarding | 27.5 h | 17.2 h | 5.3 h | 1.8 h | 735 |
Is any of it getting better
Billing's row stands out in that table. Resampling weekly and taking a rolling median says whether that is a permanent state of affairs or something that was already resolving itself.
1import matplotlib.pyplot as plt23data = make_tickets()45weekly = (6 data.set_index("opened")7 .groupby("team", observed=True)["hours_to_close"]8 .resample("W")9 .median()10 .unstack("team")11)12smooth = weekly.rolling(3, min_periods=1).median()1314fig, ax = plt.subplots(figsize=(10, 4.6), constrained_layout=True)15for team in TEAMS:16 ax.plot(smooth.index, smooth[team], linewidth=2.0, label=team)17ax.set_ylabel("median hours to close")18ax.set_xlabel("")19ax.legend(frameon=False, ncols=4, loc="upper center")20ax.set_ylim(0, smooth.to_numpy().max() * 1.25)21for side in ("top", "right"):22 ax.spines[side].set_visible(False)23plt.show()
Make it yours
Billing converges on the other three by about March. The backlog was real and it cleared, which is a different answer from the pivot table's, and the reason to look at both.
Download the notebook and swap median for mean in the pivot. The urgent
column barely moves and the low column jumps, because a handful of tickets sat
open for weeks. Which of those two numbers is the honest one depends entirely
on the question, and the notebook is where that argument is easiest to have.
Run it yourself
Nothing on this page is executable; the outputs were baked in by a real run. Download the notebook and it runs anywhere Verso does: VS Code, the browser, or the terminal.
dotnet tool install --global Verso.Cliverso serve ticket-report.versoWhat this shows
Six months of support tickets through pivot tables, a color-ramped summary, and a rolling weekly median. The pivot and the trend disagree, which is exactly why you draw both.
Every language in this notebook reads and writes the same variable store, so a value produced in one cell is simply there in the next, whatever the language.