Skip to content

Instantly share code, notes, and snippets.

@wtberry
Created June 23, 2019 22:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wtberry/199bbc5ae79bab48eae3fa03ee8607a0 to your computer and use it in GitHub Desktop.
Save wtberry/199bbc5ae79bab48eae3fa03ee8607a0 to your computer and use it in GitHub Desktop.
from sklearn.feature_extraction.text import CountVectorizer
# Initialize and fit CountVectorizer with given text documents
vectorizer = CountVectorizer().fit(df['name'])
# use the vectorizer to transform the document into word count vectors (Sparse)
word_mat = vectorizer.transform(df['name'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment