Year-over-Year Growth by Month

medium
Unit 11 · Pandas IV0/3 to milestone

df has columns month (strings like "2024-03") and revenue, with possibly missing months. Implement yoy(df) returning a DataFrame with columns month, revenue and yoy_pct: the percentage change versus the same month one year earlier, rounded to 1 decimal place, or NaN if that month isn't in the data. Sort by month.

Match on the actual calendar month, not on row position (missing months would break shift(12)).

#pandas#time-series2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Year-over-Year Growth by Month · TechGradify