Skip to content

Instantly share code, notes, and snippets.

@importdata
Created May 18, 2020 02:16
Show Gist options
  • Save importdata/f3ba5ce430f2617a50f66829942e2d97 to your computer and use it in GitHub Desktop.
Save importdata/f3ba5ce430f2617a50f66829942e2d97 to your computer and use it in GitHub Desktop.
Kaggle Twitter Data CountVectorizer Example
document = ["This is Import Data's YouTube channel",
"Data Science is my passion and it is fun",
"Please subscribe to my channel"]
# create the transform
vectorizer = CountVectorizer()
# tokenize and make the document into a matrix
doc_term_matrix = vectorizer.fit_transform(document)
pd.DataFrame(doc_term_matrix.toarray(),columns = vectorizer.get_feature_names())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment