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)
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
i solved it. b.reshape(1,2,3), then d=np.vstack((c,b))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.