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

PythonArraysNumpy

Python Problem Overview


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

Python Solutions


Solution 1 - Python

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

x=np.concatenate((x, s_x))

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSanthoshView Question on Stackoverflow
Solution 1 - PythonNils WernerView Answer on Stackoverflow