SciPy

scipy.sparse.coo_matrix.diagonal

coo_matrix.diagonal()[source]

Returns the main diagonal of the matrix