ExpertDates & Time50 points

Week-over-week traffic growth

A marketing lead reviews each channel weekly. Partial weeks at the start or end of an export would distort growth, so they must be ignored. Data: traffic.csv, one row per source per day for 60 days from Wednesday 2025-03-05.

  • date: YYYY-MM-DD
  • source: Organic Search, Paid Ads, Email or Social
  • sessions: visits that day
  • signups: new accounts that day

Task: the input is a source name or ALL (all four sources added together). Group days into ISO weeks (date.isocalendar(), weeks run Monday to Sunday). Keep only weeks for which the data has all 7 days. For each kept week, in order, print YYYY-Www SESSIONS CHANGE where week is like 2025-W11, and CHANGE is the percent change versus the previous kept week as a signed 1-decimal percent (+4.2%), or n/a for the first kept week. End with Best week: WEEK CHANGE for the highest change (earliest if tied).

Files your program can read

traffic.csv241 lines
date,source,sessions,signups
2025-03-05,Organic Search,704,37
2025-03-05,Paid Ads,390,23
2025-03-05,Email,237,10
2025-03-05,Social,472,24
2025-03-06,Organic Search,921,54
2025-03-06,Paid Ads,539,31
2025-03-06,Email,336,18
...

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

Sample test

Input

Organic Search

Expected output

2025-W11 6001 n/a
2025-W12 5516 -8.1%
2025-W13 6456 +17.0%
2025-W14 6280 -2.7%
2025-W15 6725 +7.1%
2025-W16 6998 +4.1%
2025-W17 6711 -4.1%
Best week: 2025-W13 +17.0%

Your answer is also checked against 4 hidden tests.

Need a hint?

Count the distinct dates per week, not the rows, because every date appears once per source.