Given this numpy array
[[200. 202.08165 ]
[189.60295 190.32434 ]
[189.19751 188.7867 ]
[162.15639 164.05934 ]]
I want to get this array
[[200. 190.32434 ]
[189.60295 188.7867 ]
[189.19751 164.05934 ]]
The same for 3 columns, given this array
[[200. 202.08165 187.8392 ]
[189.60295 190.32434 167.93082]
[189.19751 188.7867 199.2839 ]
[162.15639 164.05934 200.92 ]]
I want to get this array
[[200. 190.32434 199.2839 ]
[189.60295 188.7867 200.92 ]]
Any vectorized way to achieve this for any number of columns and rows? np.diag
and np.diagonal
only seem to give me a single diagonal, but I need all of them stacked up.