Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created January 26, 2021 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/4271ef3dd4b965500551d827b3f3f80a to your computer and use it in GitHub Desktop.
Save amankharwal/4271ef3dd4b965500551d827b3f3f80a to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
from wordcloud import WordCloud, STOPWORDS
stopwords = set(STOPWORDS)
stopwords.add('will')
import re
import seaborn as sns
sns.set()
plt.style.use('seaborn-whitegrid')
def WordCloudPlotter(dfColumn):
colData = data[dfColumn]
textCloud = ''
#text processing
# converting colums to a
#single line of text
for mem in colData:
textCloud = textCloud + str(mem)
# plotting word cloud
wordcloud = WordCloud(width = 800, height = 800,background_color ='white',
stopwords = stopwords, min_font_size = 10).generate(textCloud)
plt.figure(figsize = (8, 8), facecolor = None)
plt.style.use('seaborn-whitegrid')
plt.imshow(wordcloud)
plt.rcParams.update({'font.size': 25})
plt.axis("off")
plt.title('Word Cloud: ' + str(dfColumn))
plt.tight_layout(pad = 0)
plt.show()
WordCloudPlotter('Caption')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment