import pandas as pd
mydate = ["01/01/2018","19/01/2018","24/01/2018" ,
"27/01/2018","29/01/2018","30/01/2018" ,
"22/02/2018","23/03/2018"]
mydate = pd.to_datetime(mydate)
events = ["a" , "b" , "c" , "d" , "e" , "f" ,"g" , "h"]
df = pd.DataFrame({"date" :mydate,"events" :events})
df
date events
0 2018-01-01 a
1 2018-01-19 b
2 2018-01-24 c
3 2018-01-27 d
4 2018-01-29 e
5 2018-01-30 f
6 2018-02-22 g
7 2018-03-23 h
I want to slice data on every 20 days and store them in separate data frame. I have looked group-by , date_range and other functionality but could not find solution for my problem. I can do this using typical for loop but I am looking to do using some pandas functionality.
Expected result
df = [df1 , df2 , df3 , df4]
where df1 contain row 0 ,1
df2 contains row 2,3,4,5
df3 contain row 6
df4 contain row 7