0

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

3
  • (300, ) do not have columns . Commented Jul 22, 2019 at 18:47
  • column_stack turns (n,) shaped arrays into (n,1) shaped before concatenating. In other words, it turns the 1d inputs into column vectors and tries to join those columns. The full error message shows the code that does this. Commented Jul 22, 2019 at 19:25
  • You are trying to concatenate the first row of each array. The rows have different sizes. Commented Jul 22, 2019 at 19:29

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.