tocsc — SciPy v1.15.2 Manual (original) (raw)
scipy.sparse.coo_matrix.
coo_matrix.tocsc(copy=False)[source]#
Convert this array/matrix to Compressed Sparse Column format
Duplicate entries will be summed together.
Examples
from numpy import array from scipy.sparse import coo_array row = array([0, 0, 1, 3, 1, 0, 0]) col = array([0, 2, 1, 3, 1, 0, 0]) data = array([1, 1, 1, 1, 1, 1, 1]) A = coo_array((data, (row, col)), shape=(4, 4)).tocsc() A.toarray() array([[3, 0, 1, 0], [0, 2, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]])