There is a nonzero() method for the csr_matrix of scipy library, however trying to use th开发者_开发百科at function for csr matrices result in an error, according to the manual that should return a tuple with row and colum arrays. Any ideas on this problem?
Best regards, Umut
Umut, could you provide a code snippet? The following works for me:
import scipy.sparse as sparse
x = sparse.csr_matrix([[1,0,1],[0,1,0]])
x.nonzero()
and yields
(array([0, 0, 1], dtype=int32), array([0, 2, 1], dtype=int32))
This is for the latest development version of scipy (you can check by printing scipy.__version__
).
精彩评论