title: Python: Concatenating scipy sparse matrix
body: <p>I am trying to Concatenate 2 sparse matrix by the help of hstack function. xtrain_cat is the output of DictVectorizer(encodes categorical values) and xtrain_num is a pandas cvs file.</p>
  
  <pre><code>    xtrain_num = sparse.csr_matrix(xtrain_num)
      print type(xtrain_num)
      print xtrain_cat.shape
      print xtrain_num.shape
      x_train_data = hstack(xtrain_cat,xtrain_num)
  </code></pre>
  
  <p>Error :</p>
  
  <pre><code>(1000, 2778)
  &lt;class 'scipy.sparse.csr.csr_matrix'&gt;
  &lt;class 'scipy.sparse.csr.csr_matrix'&gt;
  (1000, 2778)
  (1000, 968)
  Traceback (most recent call last):
    File "D:\Projects\Zohair\Bosch\Bosch.py", line 360, in &lt;module&gt;
      x_train_data = hstack(xtrain_cat,xtrain_num)
    File "C:\Users\Public\Documents\anaconda2\lib\site-packages\scipy\sparse\construct.py", line 464, in hstack
      return bmat([blocks], format=format, dtype=dtype)
    File "C:\Users\Public\Documents\anaconda2\lib\site-packages\scipy\sparse\construct.py", line 547, in bmat
      raise ValueError('blocks must be 2-D')
  ValueError: blocks must be 2-D
  </code></pre>
  
  <p>Can someone identify what is the probelm</p>