CCIEGZM
CCIEGZM

Reputation: 105

merge numpy array together

a1=array([[0, 1, 2, 3, 4],
   [5, 6, 7, 8, 9]])
a2=array([[0, 1],
   [2, 3]])
a3 = array([[0, 1, 2, 3, 4, 0, 1],
   [5, 6, 7, 8, 9, 2, 3]])

I have two arrays a1,a2,I want to merge them together.the result is a3

Upvotes: 2

Views: 606

Answers (2)

seven7e
seven7e

Reputation: 818

np.c_[a1, a2]

also a np.r_ for row-wise merging.

Upvotes: 1

farhawa
farhawa

Reputation: 10417

Using numpy np.concatenate() this way should work

 a3 = np.concatenate((a1,a2),axis = 1)

Upvotes: 1

Related Questions