Guest User

Untitled

a guest
Oct 20th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. from sklearn.feature_extraction.text import TfidfVectorizer
  2. tfidf_vectorizer = TfidfVectorizer(norm=None)
  3.  
  4. list_contents =[]
  5. for index, row in df.iterrows():
  6. list_contents.append(' '.join(row.Tokens))
  7.  
  8. # list_contents = df.Content.values
  9.  
  10. tfidf_matrix = tfidf_vectorizer.fit_transform(list_contents)
  11. df_tfidf = pd.DataFrame(tfidf_matrix.toarray(),columns= [tfidf_vectorizer.get_feature_names()])
  12. df_tfidf.head(10)
Add Comment
Please, Sign In to add comment