1D numpy concatenate: TypeError: only integer scalar arrays can be converted to a scalar index

Question:

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
Asked By: Santhosh

||

Answers:

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

x=np.concatenate((x, s_x))
Answered By: Nils Werner
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.