Chapter 10 · 8 levels

Time series

Turn timestamps into trends with resample, rolling windows, period-over-period growth, date offsets and gap filling, on three years of Harbor & Pine orders.

Start

Almost every report an analyst sends has time on one axis: orders per month, revenue per week, a seven-day average on a dashboard, this November against last November. pandas has a whole toolkit for this, built around a DatetimeIndex: once the timestamps are the index, you can regroup them into any calendar period, slide windows across them and compare a period with the one before.

Harbor & Pine’s data covers three full years, 2023 to 2025, with a strong holiday season and a Black Friday spike, so the trends are real enough to be worth finding. You’ll count orders per month with resample, build monthly revenue, smooth a noisy daily series with rolling, measure month-over-month and year-over-year growth, work with date offsets like “30 days after the order”, and find and fill gaps in the marketing spend log.

The chapter ends with a boss level: a holiday-season review for the CEO, built from daily revenue, rolling windows and year-over-year growth.

Levels

  1. Orders per month with resample

    from Megan Collins, Head of Sales

    datetimeindex, resample, set index, month start, size

    Code Difficulty 2 of 5 Not started

  2. Monthly revenue from order lines

    from Laura Bennett, Head of Finance

    resample, merge, sum, month start, line revenue

    Code Difficulty 3 of 5 Not started

  3. A 7-day average for the dashboard

    from Jordan Reyes, Head of Marketing

    rolling, moving average, resample daily, window, min periods

    Code Difficulty 3 of 5 Not started

  4. Month over month and year over year

    from Catherine Hale, Chief Executive Officer

    pct change, shift, month over month, year over year, seasonality

    Code Difficulty 3 of 5 Not started

  5. How long until a return?

    from Angela Rivera, Head of Customer Support

    timedelta, dt days, date offset, normalize, return window

    Code Difficulty 3 of 5 Not started

  6. Find and fill the tracking gaps

    from Jordan Reyes, Head of Marketing

    asfreq, date range, reindex, ffill, fillna, missing dates

    Code Difficulty 4 of 5 Not started

  7. Why don't the targets line up?

    from Megan Collins, Head of Sales

    resample, month end, month start, merge, period

    Quiz Difficulty 2 of 5 Not started

  8. Boss: the holiday season review

    from Catherine Hale, Chief Executive Officer

    rolling, day name, month name, calendar order, strftime, quarter, year over year

    Boss · 4 steps Difficulty 5 of 5 Not started

Pick what may run on this site. You can change this any time from "Cookie settings" at the bottom of every page.