I am trying to lineup date values in my df to bi-weekly format. Lets have 1st 2-weeks interval starts at 1/1/2021, the second interval starts at 1/14/2021 if df value belongs to 1st interval, i would like to see 1st interval value.
df = pd.date_range(start='1/1/2021', periods=45)
df.to_period('2W').start_time
even if i set "2W" argument, it is one-week anyway. but if I am using groupby function with "2W" - it works fine. Can you please help me to find the solution?
My ANSWER: I take week' number and converts to odd numbers. that gives me chance to agreegate df by 2 weeks interval. Hope, it will help to someone :)
df['registered_2W'] = (lambda x: x+(x+1)%2)(df['registered'].dt.strftime("%V").astype(int))