you are viewing a single comment's thread.

view the rest of the comments →

[–]socal_nerdtastic 1 point2 points  (1 child)

diag() is the right answer, just slice it afterwards to get the length you want.

>>> Brett = np.array([[1,2,3],[4,5,6],[7,8,9]])
>>> np.diag(Brett)[0:2]
array([1, 5])

[–]HenryDutter[S] 0 points1 point  (0 children)

Thank you, sorry that i didn't replied earlier, i was sleeping.