python - Concatenate each line of two arrays into a single one -
let's have 2 arrays , b.
a.shape (95, 300) b.shape (95, 3)
how can obtain new array c concatenating each of 95 lines ?
c.shape (95, 303)
iiuc, use hstack
:
>>> = np.ones((95, 300)) >>> b = np.ones((95, 3)) * 2 >>> a.shape (95, 300) >>> b.shape (95, 3) >>> c = np.hstack((a,b)) >>> c array([[ 1., 1., 1., ..., 2., 2., 2.], [ 1., 1., 1., ..., 2., 2., 2.], [ 1., 1., 1., ..., 2., 2., 2.], ..., [ 1., 1., 1., ..., 2., 2., 2.], [ 1., 1., 1., ..., 2., 2., 2.], [ 1., 1., 1., ..., 2., 2., 2.]]) >>> c.shape (95, 303)
Comments
Post a Comment