I'm trying to interleave arrays as below.
import numpy as np
x = np.array([1,2,3,4,5])
y = np.array([4,6,2,6,9], [5,9,8,7,4], [3,2,5,4,9])
Desired result:
[[1,2,3,4,5], [4,6,2,6,9], [1,2,3,4,5], [5,9,8,7,4], [1,2,3,4,5],[3,2,5,4,9]]
Is there an elegant way to do this?
This is the way I wrote it, but I was looking to improve this line, data = np.array([x, y[0], x, y[1], x, y[2]])
. Is there another way to write this?
x = np.array([1,2,3,4,5])
y = np.array([[4,6,2,6,9], [5,9,8,7,4], [3,2,5,4,9]])
data = np.array([x, y[0], x, y[1], x, y[2]])
print(data)