The CSR format has a column-oriented twin – the compressed sparse column (CSC) format. The only difference in it compared to the CSR format is the definition of the indptr and indices arrays, which are now column-related. The type for the CSC format is csc_matrix and its use corresponds to csr_matrix, explained previously in this subsection.
Continuing the same example in CSC format:
import scipy.sparse as sp A = array([[1,0,2,0],[0,0,0,0],[3.,0.,0.,0.],[1.,0.,0.,4.]]) AS = sp.csc_matrix(A) AS.data # returns array([ 1., 3., 1., 2., 4.]) AS.indptr # returns array([0, 3, 3, 4, 5]) AS.indices # returns array([0, 2, 3, 0, 3]) AS.nnz # returns 5