When I execute the following code I get a spares matrix:
import numpy as np
from scipy.sparse import csr_matrix
row = np.array([0, 0, 1, 2, 2, 2])
col = np.array([0, 2, 2, 0, 1, 2])
data = np.array([1, 2, 3, 4, 5, 6])
sp = csr_matrix((data, (row, col)), shape=(3, 3))
print(sp)
(0, 0) 1
(0, 2) 2
(1, 2) 3
(2, 0) 4
(2, 1) 5
(2, 2) 6
I want to add another column to this sparse matrix so the output is:
(0, 0) 1
(0, 2) 2
(0, 3) 7
(1, 2) 3
(1, 3) 7
(2, 0) 4
(2, 1) 5
(2, 2) 6
(2, 3) 6
Basically I want to add another column that has the values 7,7,7.