在看起来很简单的事情上遇到了一些麻烦。我想加入这两个数组以满足输出:
array([['category_1', '4500', '5000'], ['category_2', '3200', '5000'], ['category_3', '3000', '5000'], ['category_4', '2000', '5000']], dtype='<U8')
我有一些数据
data = np.array([['category_1', '4500', '5000'], ['category_2', '3200', '5000']])
我还有其他数据
other_data = np.array([['category_3', '3000', '5000'], ['category_4', '2000', '5000'])
当我这样做时,我得到这个错误
np.concatenate(data, other_data)
TypeError: only integer scalar arrays can be converted to a scalar index
答案 0 :(得分:1)
data = np.array([['category_1', '4500', '5000'], ['category_2', '3200', '5000']])
other_data = np.array([['category_3', '3000', '5000'], ['category_4', '2000', '5000']])
np.concatenate((data, other_data), axis=0)