SciPy

scipy.sparse.lil_matrix.diagonal

lil_matrix.diagonal()[source]

Returns the main diagonal of the matrix