I have an array x of 30 samples, and I wish to separate it out into chunks of 8 samples each in 2 different ways.
First, I want to separate it avoiding any overlap so that I end up with 3 arrays of length 8 and the final array will be only 6 (due to some samples being missing).
Secondly, I want to separate it so that the final array will be the last 2 samples of the previous array plus the final 6.
Both methods preferably without for loops as I'm trying to optimise this for when I expand it to arrays with lengths in the ten thousands.
I have tried using np.array_split as follows
x = np.array([1 ,1, 2 ,1 ,1 ,2 ,1, 0 ,3, 1, 2 ,2, 1, 2, 1, 1,50,1 ,1, 1, 1, 4, 1, 11, 15, 0, 0, 1, 1,0])
y = np.array_split(x,np.ceil(len(x)/8))
However, that results in:
y = [array([1, 1, 2, 1, 1, 2, 1, 0]),
array([3, 1, 2, 2, 1, 2, 1, 1]),
array([50, 1, 1, 1, 1, 4, 1]),
array([11, 15, 0, 0, 1, 1, 0])]
so y is clearly made up of 2x8 length arrays and 2x7 length arrays, not what I want. How do I go about achieving it the way I want. The first method is the more important, the second is a bonus.
Thanks