Extremely ugly but performant code to group by monthly data into years.