title: How to hstack several sparse matrices (feature matrices)?
body: <p>I have 3 sparse matrices:</p>
  
  <pre><code>In [39]:
  
  mat1
  
  
  Out[39]:
  (1, 878049)
  &lt;1x878049 sparse matrix of type '&lt;type 'numpy.int64'&gt;'
      with 878048 stored elements in Compressed Sparse Row format&gt;
  
  In [37]:
  
  mat2
  
  
  Out[37]:
  (1, 878049)
  &lt;1x878049 sparse matrix of type '&lt;type 'numpy.int64'&gt;'
      with 744315 stored elements in Compressed Sparse Row format&gt;
  
  In [35]:
  
  mat3
  
  
  
  Out[35]:
  (1, 878049)
  &lt;1x878049 sparse matrix of type '&lt;type 'numpy.int64'&gt;'
      with 788618 stored elements in Compressed Sparse Row format&gt;
  </code></pre>
  
  <p>From the <a href="https://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.hstack.html" rel="noreferrer">documentation</a>, I read that it is possible to <code>hstack</code>, <code>vstack</code>, and <code>concatenate</code> them such type of matrices. So I tried to <code>hstack</code> them:</p>
  
  <pre><code>import numpy as np
  
  matrix1 = np.hstack([[address_feature, dayweek_feature]]).T
  matrix2 = np.vstack([[matrix1, pddis_feature]]).T
  
  
  X = matrix2
  </code></pre>
  
  <p>However, the dimensions do not match:</p>
  
  <pre><code>In [41]:
  
  X_combined_features.shape
  
  Out[41]:
  
  (2, 1)
  </code></pre>
  
  <p>Note that I am stacking such matrices since I would like to use them with a scikit-learn classification algorithm. Therefore, <strong>How should I <code>hstack</code> a number of different sparse matrices?</strong>.</p>