Created
December 18, 2018 09:51
-
-
Save jonathanoheix/92f49d304186796b4a9fb211db2450f0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 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