I have seen a lot of similar posts on "nth weekday of the month", but my question pertains to "nth weekday of the year".
Background: I have a table that has daily sales data. There are 3 columns: date, day of week (Mon, Tue, Wed etc.) and sales. I would like to match nth weekday of Year 1 with Year 2 and compare sales that way.
- Example1: 01/06/2020 matches with 01/04/2021, both are the 1st Monday of that year.
- Example2: 11/02/2019 matches with 10/31/2020, both are the 44th Saturday of that year.
As you can see, I can't simply do a "nth weekday of the MONTH" because sometimes the matched nth weekday would fall in different months (as seen in 11/02/2019 & 10/31/2020).
I am manipulating the table in pandas. I am wondering if there's a quick way for me to create a column that helps me to calculate the "nth weekday of the year" for me, so that I could later match based on that value?
Thanks for your help.