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
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