scipy.sparse.csr_array.nonzero#
- csr_array.nonzero()[source]#
Nonzero indices of the array/matrix.
Returns a tuple of arrays (row,col) containing the indices of the non-zero elements of the array.
Examples
>>> from scipy.sparse import csr_array >>> A = csr_array([[1,2,0],[0,0,3],[4,0,5]]) >>> A.nonzero() (array([0, 0, 1, 2, 2]), array([0, 1, 2, 0, 2]))