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
#Define a list of stop words | |
stopwords = ['private', 'tour', 'transfer', 'guide', 'skip', 'line', | |
'skiptheline', 'vice', 'versa'] | |
#A function to generate the word cloud from text | |
def generate_basic_wordcloud(data, title): | |
cloud = WordCloud(width=400, | |
height=330, | |
max_words=150, | |
colormap='tab20c', |
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
# Store our document term matrix data for Rome | |
data = dtm.transpose()['Rome, Italy'].sort_values(ascending=False) | |
# Generate the word cloud from frequencies | |
wc = WordCloud().generate_from_frequencies(data) | |
plt.imshow(wc) | |
plt.axis('off') | |
plt.show() |
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
#Give our Rome corpus a variable name | |
rome_corpus = df.lemmatized[10] | |
#Instantiate wordcloud object and use method to feed it our corpus | |
wc = WordCloud().generate_from_text(rome_corpus) | |
#Use matplotlib.pyplot to display the fitted wordcloud | |
#Turn axis off to get rid of axis numbers | |
plt.imshow(wc) | |
plt.axis('off') |
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
from wordcloud import WordCloud, ImageColorGenerator | |
from PIL import Image | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
import numpy as np |
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
!!! 5 | |
html(class='no-js') | |
head | |
meta(charset='utf-8') | |
meta(http-equiv='X-UA-Compatible', content='IE=edge') | |
title | |
meta(name='description', content='') | |
meta(name='viewport', content='width=device-width, initial-scale=1') |