Skip to content

Instantly share code, notes, and snippets.

@jonathanoheix
Created December 18, 2018 09:51
Show Gist options
  • Save jonathanoheix/92f49d304186796b4a9fb211db2450f0 to your computer and use it in GitHub Desktop.
Save jonathanoheix/92f49d304186796b4a9fb211db2450f0 to your computer and use it in GitHub Desktop.
# wordcloud function
from wordcloud import WordCloud
import matplotlib.pyplot as plt
def show_wordcloud(data, title = None):
wordcloud = WordCloud(
background_color = 'white',
max_words = 200,
max_font_size = 40,
scale = 3,
random_state = 42
).generate(str(data))
fig = plt.figure(1, figsize = (20, 20))
plt.axis('off')
if title:
fig.suptitle(title, fontsize = 20)
fig.subplots_adjust(top = 2.3)
plt.imshow(wordcloud)
plt.show()
# print wordcloud
show_wordcloud(reviews_df["review"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment