title: How to sum a sparse matrix rows in the first column, and zero the other colums, with the same dimensions of the original matrix?
body: <p>I have a sparse matrix B, I want to get the sparse matrix A from B by summation of all rows in the first column, then dividing the first column by '2', and making the other columns zero.</p>
  
  <pre><code>from numpy import array
  from scipy import csr_matrix
  
  row = array([0,0,1,2,2,2])
  col = array([0,2,2,0,1,2])
  data = array([1,2,3,4,5,6])
  
  B = csr_matrix( (data,(row,col)), shape=(3,3) )
  
  A = B.copy()
  
  A = A.sum(axis=1)/2
  # A shape becomes 1 x 3 instead of 3 x 3 here!
  </code></pre>