title: How to convert sparse matrix to dense form using python
body: <p>I have the following matrix which I believe is sparse. I tried converting to dense using the x.dense format but it never worked. Any suggestions as to how to do this?, thanks.</p>
  
  <pre><code>mx=[[(0, 2), (1, 1), (2, 1), (3, 1), (4, 1), (5, 3), (6, 4), (7, 2), (8, 5), (9, 1)], 
  [(10, 1), (11, 5), (12, 2), (13, 1), (21, 1), (22, 1), (23, 1), (24, 1), (25, 1), (26, 2)], 
  [(27, 2), (28, 1), (29, 1), (30, 1), (31, 2), (32, 1), (33, 1), (34, 1), (35, 1), (36, 1)]]
  </code></pre>
  
  <p>someone put forward the solution below, but is there a better way?</p>
  
  <pre><code>def assign_coo_to_dense(sparse, dense):
      dense[sparse.row, sparse.col] = sparse.data
  </code></pre>
  
  <p>mx.todense(). 
    Intended output should appear in this form:[[2,1,1,1,1,3,4], [1,5,2,1,1,1,1], [2,1,1,1,2,1,1,1]]</p>