1

I'm trying to add a new array to another array at after row 1,

a=np.arange(1,17).reshape(4,4)
b=np.zeros((1,4),dtype=np.uint8)
c=np.concatenate((a,b),0)

When i try this it adds it after the last row

[[ 1  2  3  4]
 [ 5  6  7  8]
 [ 9 10 11 12]
 [13 14 15 16]
 [ 0  0  0  0]]

I want to add it after row 1 so it should look like this

[[ 1  2  3  4]
 [ 5  6  7  8]
 [ 0  0  0  0]
 [ 9 10 11 12]
 [13 14 15 16]]
user462206
  • 15
  • 3

1 Answers1

0

c = np.insert(a, 2, b, axis=0)

Numpy Insert (documentation)

Nicolas Gervais
  • 28,901
  • 11
  • 96
  • 121