Last active
April 1, 2021 10:11
-
-
Save abhishek-shrm/aab022b47ea0f05794504c8df38e62b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Creating Document Term Matrix | |
from sklearn.feature_extraction.text | |
import CountVectorizer | |
cv=CountVectorizer(analyzer='word') | |
data=cv.fit_transform(df_grouped['lemmatized']) | |
df_dtm = pd.DataFrame(data.toarray(), columns=cv.get_feature_names()) | |
df_dtm.index=df_grouped.index | |
df_dtm.head(3) |
Thank you for pointing it out. I have updated the code.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
just a note about this code: in Python you need to separate it (two lines)
from sklearn.feature_extraction.text import CountVectorizer
cv=CountVectorizer(analyzer='word')