-1

I am self-answering the following question as when I made the following mistake, I couldn't find an answer.

a = np.array([1,2,3])
b = np.array([4,5,6])

np.concatenate(a, b)

Produces the following error:

TypeError: only integer scalar arrays can be converted to a scalar index

1

2 Answers 2

0

This works:

a = np.array([1,2,3])
b = np.array([4,5,6])

print(np.concatenate((a.reshape(3, 1), b.reshape(3, 1)), axis = 1))
Sign up to request clarification or add additional context in comments.

Comments

-1

The arrays to be concatenated need to be wrapped in parentheses:

np.concatenate((a, b))
>>> array([1, 2, 3, 4, 5, 6])

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.