I have a pandas data frame like so:
A | B | C | index
-----------------
a1 | b1 | c1 | 1
a2 | b2 | c2 | 2
a3 | b3 | c3 | 3
a4 | b4 | c4 | 4
a5 | b5 | c5 | 5
This resembles a time series ordered by the index (or date column if you will)
My goal is to create n data frames with each having 3 entries in order. So the solution would be the following in the above example:
df1)
A | B | C | index
-----------------
a1 | b1 | c1 | 1
a2 | b2 | c2 | 2
a3 | b3 | c3 | 3
df2)
A | B | C | index
-----------------
a2 | b2 | c2 | 2
a3 | b3 | c3 | 3
a4 | b4 | c4 | 4
df3)
A | B | C | index
-----------------
a3 | b3 | c3 | 3
a4 | b4 | c4 | 4
a5 | b5 | c5 | 5
How can I do that in python 3.5 and pandas? In other languages I would probably take a for loop and iterate over i in range(1,len(df)-2), but I am guessing there is a much more pythonic solution to this.
Thanks in advance for your help!! :-)