Matrix indexing in Numpy

前端 未结 2 1222
小鲜肉
小鲜肉 2021-01-05 06:48

I was growing confused during the development of a small Python script involving matrix operations, so I fired up a shell to play around with a toy example and develop a bet

2条回答
  •  醉梦人生
    2021-01-05 07:09

    Imagine you have the following

    >> A = np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]]) 
    

    If you want to get the second column value, use the following:

    >> A.T[1]
    array([ 2,  6, 10])
    

提交回复
热议问题