I am looking to find the current week of the month. There are many answers already on this here but i have below scenario:
Week starts from Sunday-Saturday
When month changes, majority of the dates should be considered. Example, 30th March 2020 is Week1 of April since in that week, there are 3 dates of March(29, 30, 31) but 4 dates of April(1,2,3,4).
Sample start dates and end dates are shown below:
start date end date
Jan 1 12/29/2019 2/1/2020
Feb 2 2/2/2020 2/29/2020
Mar 3 3/1/2020 3/28/2020
Apr 4 3/29/2020 5/2/2020
May 5 5/3/2020 5/30/2020
Jun 6 5/31/2020 6/27/2020
Jul 7 6/28/2020 8/1/2020
Aug 8 8/2/2020 8/29/2020
Sep 9 8/30/2020 9/26/2020
Oct 10 9/27/2020 10/31/2020
Nov 11 11/1/2020 11/28/2020
Dec 12 11/29/2020 12/26/2020
I am doing it via pd.merge where i have created complete table for 1 year which i can lookup and find the date but i am looking for something automated which will not be required to be updated every year.