80

I want to store numpy array into to another numpy array

I am using np.concatenate

This is my code

x=np.concatenate(x,s_x)

These are the type and the shape of x and s_x

Type of s_x: <class 'numpy.ndarray'>, Shape of s_x: (173,)
Type of x: <class 'numpy.ndarray'> (0,), Shape of x: (0,)

This is the error being displayed

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

1 Answer 1

173

You need to pass the arrays as an iterable (a tuple or list), thus the correct syntax is

x=np.concatenate((x, s_x))
Sign up to request clarification or add additional context in comments.

4 Comments

For such a common and useful function it really does have the most useless error messages. Thanks!
Python is great, but it's this kind of nitpicking that makes it a pain in the neck sometimes.
I am lucky to scroll down the google search results enough and find this answer.
@UlissesBraga-Neto problem is not with Python but rather with numpy. The error message should be more informative.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.