Skip to content

Instantly share code, notes, and snippets.

Created Aug 27, 2020
What would you like to do?
Create a Simple Wordcloud using Donald Trump's Tweets
import json
from wordcloud import WordCloud
import matplotlib.pyplot as plt
with open('data/trump_tweets/condensed_2018.json') as f:
data = json.load(f)
type(data), len(data)
text_list = []
for tweet in data:
# Combine all the Tweets into one giant String.
text = "".join(text_list)
#Do some light text manipulation. Drop "stop words" from appearing in the Wordcloud
drop_words = ['&', '', ' now ', 'https']
for dw in drop_words:
text = text.replace(dw, "")
# Generate a word cloud image
wordcloud = WordCloud().generate(text)
wordcloud = WordCloud(max_font_size=40).generate(text)
plt.imshow(wordcloud, interpolation="bilinear")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment