I get unpleasant behavior when I set the values โโin .data of csr_matrix zero. Here is an example:
from scipy import sparse a = sparse.csr_matrix([[0,0,2,0], [1,1,0,0],[0,3,0,0]])
Output:
>>> aA array([[0, 0, 2, 0], [1, 1, 0, 0], [0, 3, 0, 0]]) >>> a.data array([2, 1, 1, 3]) >>> a.data[3] = 0
What is the best practice in the above situation? Should I avoid setting .data elements to zero? Wrong way .nnz find the number of zeros?
source share