I noticed that the week function considers both these dates as the 53rd week of 2020.
Is there either:
There is a way for the Dates.jl package to tell me that January 1 2021 is the 53rd week of 2020 specifically, rather than just the 53rd week of a year?
Preferably, is there an alternative week function, where the week counter resets at the start of each year, so January 1 2021 is the first week of 2021?
TLDR: I don’t have to depart from that standard, but it’d be nice to know the accompanying year of a given week, so I can easily know that January 1 2021 is the 53rd week of 2020, not 2021.
Long version: I have a Date column in my dataset, which is across multiple years. I wanted to do some aggregating calculations at the weekly level, so I was going to extract the week and year from the Date column. However, this wouldn’t work for January 1 2021 - it’d be recorded as the 53rd week of 2021.
But if you move that week, Dec 31 I suddenly in the next year? You have to hit a year where Sunday is the 31st and Monday is the 1st, for not having this problem. In all other years either of those days is “in the wrong year” (or in the right one at least according to the ISO definition).
One thing you could do, is introducing a week 0 – but also then be careful to then not accidentally counting the week twice (in both years).