I have two numpy arrays and would like to merge them with the following rule desirably without using any for loop.
- Take the first n rows from the first array.
- Add the first m rows from the second array.
- Add rows between n and 2n from the first array.
- Add rows between m and 2m from the second array.
.....
- Add the last m rows from the second array.
For instance, let's say I have two arrays and n=2, m=3
x = np.random.randint(10, size=(10, 6))
y = np.random.randint(20, size=(12, 6))
[[5 0 2 2 6 1]
[4 8 9 2 7 2]
[5 5 0 5 3 0]
[2 1 4 7 9 4]
[8 1 1 9 2 8]
[4 1 1 0 1 1]
[2 9 3 5 7 9]
[3 6 6 6 0 4]
[4 4 7 3 7 9]
[7 3 7 1 5 2]]
[[ 3 15 3 8 12 12]
[19 12 13 0 19 16]
[11 2 18 16 9 19]
[19 15 15 11 13 2]
[19 14 1 6 13 17]
[19 14 19 14 13 3]
[ 0 1 13 0 19 10]
[19 13 19 5 16 13]
[12 4 15 11 12 17]
[ 4 19 17 2 11 12]
[ 9 12 10 9 15 3]
[13 7 2 5 13 10]]
The desired output is
[[5 0 2 2 6 1]
[4 8 9 2 7 2]
[ 3 15 3 8 12 12]
[19 12 13 0 19 16]
[11 2 18 16 9 19]
[5 5 0 5 3 0]
[2 1 4 7 9 4]
[19 15 15 11 13 2]
[19 14 1 6 13 17]
[19 14 19 14 13 3]
[8 1 1 9 2 8]
[4 1 1 0 1 1]
[ 0 1 13 0 19 10]
[19 13 19 5 16 13]
[12 4 15 11 12 17]
[2 9 3 5 7 9]
[3 6 6 6 0 4]
[ 4 19 17 2 11 12]
[ 9 12 10 9 15 3]
[13 7 2 5 13 10]
[4 4 7 3 7 9]
[7 3 7 1 5 2]