Created
September 6, 2020 17:27
-
-
Save liannewriting/3b2962b65342902dc31b73545fb13a64 to your computer and use it in GitHub Desktop.
Twitter sentiment analysis python
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
# stopwords do not appear in the wordcloud. | |
stopwords = STOPWORDS.copy() | |
stopwords.update(['http', 'https', 'co', 'starbuck', 'starbucks']) # add some additional stopwords. | |
# make all the text lowercase and combine everything together. | |
all_txt = [txt.lower() for txt in df_starbucks['full_text'].to_list()] | |
all_txt = ' '.join(all_txt) | |
# create and plot the wordcloud. | |
wordcloud = WordCloud(stopwords=stopwords, background_color="white", width=800, height=600).generate(all_txt) | |
plt.figure(figsize=(15,10)) | |
plt.imshow(wordcloud, interpolation='bilinear') | |
plt.axis("off") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment