IntermediateData Analysis25 points

Support team scorecard (two files)

A call centre manager wants a scorecard for each team. Ticket data and staff data live in two files joined by agent_id.

  • tickets.csv: ticket_id, agent_id, priority, handle_min (minutes spent), csat (customer rating 1 to 5, empty when the customer did not answer)
  • agents.csv: agent_id, name, team (Billing, Technical or Onboarding)

Task: the first input line is a team name, the second line an integer min_tickets. For every agent of that team with at least min_tickets tickets print Name | N | A | C where N is the ticket count, A the average handle_min with 1 decimal, and C the average of the ratings that are present with 2 decimals (print n/a if the agent has no ratings). Sort agents by A ascending using the exact average, ties by name. If nobody qualifies print No agents.

Files your program can read

tickets.csv211 lines
ticket_id,agent_id,priority,handle_min,csat
T7001,A06,Low,43,2
T7002,A05,Low,35,
T7003,A02,High,21,1
T7004,A11,Medium,34,4
T7005,A08,Medium,29,2
T7006,A05,High,43,
T7007,A04,Low,15,5
...
agents.csv13 lines
agent_id,name,team
A01,Amara Okafor,Billing
A02,Luis Ortega,Billing
A03,Priya Nair,Billing
A04,Jonas Weber,Billing
A05,Mei Tanaka,Technical
A06,Omar Haddad,Technical
A07,Sofia Rossi,Technical
...

Open them by name, for example open("tickets.csv").

Sample test

Input

Billing
5

Expected output

Amara Okafor | 30 | 14.2 | 3.00
Luis Ortega | 26 | 16.2 | 3.05
Priya Nair | 23 | 16.7 | 2.91
Jonas Weber | 18 | 17.7 | 3.31

Your answer is also checked against 4 hidden tests.