Numpy array, insert alternate rows of zeros

numpy, python

Solution

You could do this by initialising a 982-row array first and then filling alternate rows, for example (5 columns):

a=np.zeros((982,5)) 
b=np.random.randint(0,100,(491,5)) # your 491 row matrix
a[::2] = b

Problem

I am trying to modify a NumPy array by adding a row of zeros after each row. My matrix has 491 rows and I should end up with a matrix that has 982 rows. I tried multiple ways using `np.repeat`, `np.tile` and so on to no avail. Can anyone help me with this issue?

Original source