Syntax in Python (.T)

后端 未结 3 678
被撕碎了的回忆
被撕碎了的回忆 2020-12-08 06:21

In the help resource for the multivariate normal sampling function in SciPy, they give the following example:

x,y = np.random.multivariate_normal(mean,cov,50         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-08 06:30

    Example

    import numpy as np
    a = [[1, 2, 3]]
    b = np.array(a).T  # ndarray.T The transposed array. [[1,2,3]] -> [[1][2][3]]
    print("a=", a, "\nb=", b)
    for i in range(3):
        print(" a=", a[0][i])  # prints  1 2 3
    for i in range(3):
        print(" b=", b[i][0])  # prints  1 2 3 
    

提交回复
热议问题