I've been trying to do something like a numpy.array_split(), but to split it like this instead:
So It would return an array (for example let's call it output[] ) with n 2D subarrays inside of it.
For example (for n = 3):
- output[0] would return the (yellow) subarray with columns a1, a4, a7, a10,
- output[1] would return the (red) subarray with columns a2, a5, a8,
- output[2] would return the (blue) subarray with columns a3, a6, a9.
def split(arr, n):
output= [[] for _ in range(n)]
for v, help in zip(arr, cycle(out)):
help.append(v)
return output
I don't know how to combine rows into one 2D array, so I have many 1D arrays instead of one 2D.