如何在python中将(n,)矩阵转换为(1,n)矩阵

时间:2017-04-07 08:39:59

标签: python

如何在Python中将(n,)矩阵转换为(1,n)numpy矩阵

我尝试使用transpose使它成为(n,1),这不是我想要的

2 个答案:

答案 0 :(得分:1)

我猜你指的是Numpy的ndarray 您只需申请reshape
x = np.reshape(x, (1, n))

答案 1 :(得分:0)

x = x[:,None].T

这对我有用