title: How to get sum of each row and sum of each column in Scipy sparse matrices (csr_matrix and csc_matrix)?
body: <p>I have a very large Scipy sparse matrix ( CSR_MATRIX ). I just want to know how i can compute the sum of values for each row and also the sum of values for each column of the matrix.</p>
  
  <p>I have a code that does the same operation but it is using CSC_MATRIX. Is there anything different between these two regarding summing the rows and columns?</p>
  
  <p>I thought maybe I can get a quick response that others can also use or else I can test it myself.</p>
  
  <pre><code>from scipy.sparse import *
  from scipy import *
  row = array([0,0,1,2,2,2])
  col = array([0,2,2,0,1,2])
  data = array([1,2,3,4,5,6])
  csr_matrix( (data,(row,col)), shape=(3,3) ).todense()
  rowsums = []
  colsums = []
  #compute rowsums and colsums
  </code></pre>
  
  <p>so <code>rowsums</code> should be <code>[3, 3, 15]</code> and <code>colsum</code> should be <code>[5, 5, 11]</code>.</p>
  
  <p>I know that i can use matrix.getrow(i) and matrix.getcol(i) to get each row and column and use sum() function to get the sum but my concern is performance. I need a more efficient solution.</p>