Python: Differentiating between row and column vectors

前端 未结 12 1558
不知归路
不知归路 2020-12-07 08:56

Is there a good way of differentiating between row and column vectors in python? So far I\'m using numpy and scipy and what I see so far is that If I was to give one a vecto

12条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 09:29

    I think you can use ndmin option of numpy.array. Keeping it to 2 says that it will be a (4,1) and transpose will be (1,4).

    >>> a = np.array([12, 3, 4, 5], ndmin=2)
    >>> print a.shape
    >>> (1,4)
    >>> print a.T.shape
    >>> (4,1)
    

提交回复
热议问题