如何在numpy中将2个一维数组设置为一个矩阵?

时间:2019-01-17 10:38:43

标签: python numpy

x.shape = (256,1) 
y.shape = (256,1)

我应该如何命令?,以便它返回,

output.shape =(256,2)。

简单的问题,但我无法解决。请帮忙。

1 个答案:

答案 0 :(得分:0)

我正在使用此附加选项:

import numpy as np

matrix_1 = np.random.uniform(1, 10, (256, 1))
matrix_2 = np.random.uniform(1, 10, (256, 1))

print(matrix_1.shape)
print(matrix_2.shape)
print('-------------')

out_matrix = np.append(matrix_1, matrix_2, axis=1)
print(out_matrix.shape)