1D numpy concatenate:TypeError:只能将整数标量数组转换为标量索引

时间:2017-11-20 08:44:37

标签: python arrays numpy

我想将numpy数组存储到另一个numpy数组

我正在使用np.concatenate

这是我的代码

x=np.concatenate(x,s_x)

这些是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,)

这是显示的错误

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

1 个答案:

答案 0 :(得分:31)

您需要将数组作为可迭代(元组或列表)传递,因此正确的语法是

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