Hello All,
I'm trying to... "slide a window" acorss my data set to split it up into a series of data sets, each of which has 4 of the form of the orignal rows.
E.g, a data set with 10 rows, I want 8 new tables of this form:
row 0,1,2,3
row 1,2,3,4
...
row 7,8,9,10
I tried doing it on a simple example with a for loop:
df = pd.DataFrame(np.random.randn(10,6))
for x in range(0,7):
pieces = [df[x:x+4],]
When I try
only the last one comes up however
(that is, rows 7,8,9 and 10)
How would I do this then?
I've been told that 'using list comprehension' is a better way to do this. Is that right?