Box plots are at their best side by side: one box per group, on the same scale. Before drawing them, a bus company wants the key numbers for each route.
Task: write boxes_by_group(groups, values). Journey i was on route groups[i] and took values[i] minutes.
Return a dictionary with one key per route. Each value is a list [median, iqr, outliers] for that route's journeys only:
median and iqr are worked out the way pandas quantile does it. iqr is Q3 − Q1. Both are floats rounded to 2 decimal places.outliers is how many of that route's journeys are below Q1 − 1.5 × IQR or above Q3 + 1.5 × IQR, using the route's own quartiles. It's an int.Every route has at least one journey, and all the times are whole numbers.