title: Convert a tf-idf matrix in a pandas dataframe
body: <p>I have the following dataset:</p>
  
  <pre><code>test_set = ("The sun in the sky", "The sun in the light", "Do not blame it on moonlight", "Do not blame it on sunshine")
  </code></pre>
  
  <p>Now I use the following code to create a tf-idf matrix</p>
  
  <pre><code>from sklearn.feature_extraction.text import TfidfTransformer
  from sklearn.feature_extraction.text import CountVectorizer
  
  vectorizer = CountVectorizer()
  vectorizer.fit_transform(test_set)
  
  smatrix = vectorizer.transform(test_set)
  smatrix.todense()
  
  tfidf = TfidfTransformer(norm="l2")
  tfidf.fit(smatrix)
  tf_idf_matrix = tfidf.transform(smatrix)
  </code></pre>
  
  <p>What I would like to do now is to 'feed' this matrix to a knn cluster algorithm.
  So for example like this:</p>
  
  <pre><code>import pandas as pd
  df = pd.DataFrame([[0.2, 0.3, 0.4], [0.2, 0.3, 0.41], [0.2, 0.1, 0.05], [0.1, 0.1, 0.08]], columns=('column1', 'column2', 'column3'))
  
  k_means = cluster.KMeans(n_clusters=2) 
  k_means.fit(df)
  print(k_means.labels_)
  </code></pre>
  
  <p>I cant seem to convert the matrix into a df however. If I do:</p>
  
  <pre><code>df = pd.DataFrame(tf_idf_matrix)
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>Traceback (most recent call last):
  File "/Users/marcvanderpeet/PycharmProjects/untitled/test.py", line 47, in &lt;module&gt;
  df = pd.DataFrame(tf_idf_matrix)
  File "/Library/Python/2.7/site-packages/pandas/core/frame.py", line 345, in __init__
  raise PandasError('DataFrame constructor not properly called!')
  </code></pre>
  
  <p>pandas.core.common.PandasError: DataFrame constructor not properly called!</p>
  
  <p>Any thoughts on how I can convert this?</p>