I have to plot a wordcloud. 'tweets.csv' is a Pandas dataframe which has a column named 'text'. The ploted graph hasn't been based on the most common words, tough. How can the words sizes be linked to their frequencies in dataframe?
text = df_final.text.values
wordcloud = WordCloud(
#mask = logomask,
max_words = 1000,
width = 600,
height = 400,
#max_font_size = 1000,
#min_font_size = 100,
normalize_plurals = True,
#scale = 5,
#relative_scaling = 0,
background_color = 'black',
stopwords = STOPWORDS.union(stopwords)
).generate(str(text))
fig = plt.figure(
figsize = (50,40),
facecolor = 'k',
edgecolor = 'k')
plt.imshow(wordcloud, interpolation = 'bilinear')
plt.axis('off')
plt.tight_layout(pad=0)
plt.show()
My dataframe looks like this:
0 RT @Pontifex_pt: Temos que descobrir as riquezezas ...
1 RT @Pontifex_pt: Todos estamos em viagem rumo ...
2 RT @Pontifex_pt: Unamos as forças, em todos ...
3 RT @GeneralMourao: #Segurançapública, preocupa ...
4 RT @FIFAcom: The Brasileirao U-17 final provided ...
Setup a Sample DataFrame:
Convert the
word
&count
columns to adict
WordCloud().generate_from_frequencies()
requires adict
Wordcloud:
.generate_from_frequencies
generate_from_frequencies(frequencies, max_font_size=None)
Plot
Using an image mask: