I\'m trying to build and update a sparse matrix as I read data from file.
The matrix is of size 100000X40000
What is the most efficient way of updating
import scipy.sparse
rows = [2, 236, 246, 389, 1691]
cols = [117, 3, 34, 2757, 74, 1635, 52]
prod = [(x, y) for x in rows for y in cols] # combinations
r = [x for (x, y) in prod] # x_coordinate
c = [y for (x, y) in prod] # y_coordinate
data = [1] * len(r)
m = scipy.sparse.coo_matrix((data, (r, c)), shape=(100000, 40000))
I think it works well and doesn't need loops. I am directly following the doc
<100000x40000 sparse matrix of type ''
with 35 stored elements in COOrdinate format>