Aggregating JSON Lines

easy
Checkpoint challenge
Solve this to show you know the material and jump straight to Unit 12. Everything before it counts as cleared.

Event logs are often stored as JSON Lines (one JSON object per line). Implement aggregate(lines, group_by, metric) returning a dict mapping each group value to {"count": n, "sum": s, "avg": a} over the numeric metric field.

Skip blank lines; lines that aren't valid JSON or lack either field are counted in a separate "_errors" key (an int) instead of crashing. Sort the result's keys (the error key last, and only present if there were errors).

#json#aggregation#files2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Aggregating JSON Lines · TechGradify