I have dataframe similar to this:
dates=['2017-12-01','2017-12-05','2017-12-17','2017-12-28','2018-01-05','2018-01-09']
val=[5,2,3,6,1,7]
df = pd.DataFrame(list(zip(dates, val)),
columns =['date', 'val'])
df
date val
0 2017-12-01 5
1 2017-12-05 2
2 2017-12-17 3
3 2017-12-28 6
4 2018-01-05 1
5 2018-01-09 7
I want to crate new column that will give to each date the number of week it is between two dates.
For example, assuming that I define period that is between 01/12/2017-01/07/2018,
I'll give each date value which is number of week from 01/12.
Result for that would be something like this:
date val week_num
0 2017-12-01 5 1
1 2017-12-05 2 1
2 2017-12-17 3 3
3 2017-12-28 6 4
4 2018-01-05 1 6
5 2018-01-09 7 6
So my question is how can I give "count weeks" value for each date between two periods?