Python Forum
numpy diagonal - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: numpy diagonal (/thread-28735.html)



numpy diagonal - davidm - Aug-01-2020

hi, need help with numpy.diagonal.
Using
 grid.diagonal(0)
for a 9 by 9 matrix
I can see the diagonal [0,0} to [8,8}.
How do I see the diagonal [0,8] - [8,0]?
Also how do I display cell row and column ([0, 0]) rather than values?
Thanks for any help


RE: numpy diagonal - scidam - Aug-02-2020

Use numpy.flipud first and then .diagonal; i.e. np.flipud(x).diagonal()