一维numpy串联:TypeError:仅整数标量数组可以转换为标量索引 [英] 1D numpy concatenate: TypeError: only integer scalar arrays can be converted to a scalar index
本文介绍了一维numpy串联:TypeError:仅整数标量数组可以转换为标量索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将numpy数组存储到另一个numpy数组
I want to store numpy array into to another numpy array
我正在使用 np.concatenate
这是我的代码
x=np.concatenate(x,s_x)
这些是 x和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
推荐答案
您需要将数组作为可迭代的(元组或列表)传递,因此正确的语法是
You need to pass the arrays as an iterable (a tuple or list), thus the correct syntax is
x=np.concatenate((x, s_x))
这篇关于一维numpy串联:TypeError:仅整数标量数组可以转换为标量索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文