Cathy
Cathy

Reputation: 377

array concatenation giving error in python

I have two arrays

array_1.shape
#(961,300)


array_2.shape
#(961,9)

when I am concatenating the whole arrays I am not getting any error:

 np.column_stack((array_1,array_2))

but when I am concatenating the first element of each, I am getting the error:

array_1[0].shape
#(300,)

array_2[0].shape
#(9,)
np.column_stack((array_1[0],array_2[0]))

ValueError: all the input array dimensions except for the concatenation axis must match exactly

the first element of two arrays are here: https://www.codepile.net/pile/pP11bkPY

Upvotes: 0

Views: 67

Answers (1)

yacola
yacola

Reputation: 3013

using np.hstack instead will prevent this error, and it will give you the intended (309,)-shaped output

Upvotes: 1

Related Questions