-1

Now,i have a 3D(c) array and a 2D(b) array,i want to make a new 3D(d) array, so what shall I do? :

c=np.array([[[1, 2, 3],[2, 3, 4]],[[1, 2, 3],[2, 3, 4]]])
c.shape
(2, 2, 3)
a=np.array([[1, 2, 3],[2, 3, 4]])
a.shape
(2, 3)

d=np.array([[[1, 2, 3],[2, 3, 4]],[[1, 2, 3],[2, 3, 4]],[[1,2,3],[1,2,3]]])
d.shape
(3, 2, 3)
huahua520
  • 41
  • 2

2 Answers2

1

i solved it. b.reshape(1,2,3), then d=np.vstack((c,b))

huahua520
  • 41
  • 2
1

You first need to reshape one of them, then you can use vstack or dstack depends on which one you want to use. For example I use dstack:

c = c.reshape((2, 3, 2))
np.dstack((c, a)).shape
Binh
  • 1,143
  • 6
  • 8