Now, the first exercise is to generate the word-cloud model from the data based on the frequency of the words used. To do so, we need to work only with the Tweet_Text column, so we extract into a separate variable and change the data structure of the text to a string:
df=tweet['Tweet_Text']
#change the text to str
text=str(df)
Now we can generate the word cloud easily using the WordCloud Python library. We have used that before in Chapter 7, Modeling with Unstructured Data, so preliminary preprocessing steps have been escaped here:
wordcloud = WordCloud(background_color="white",width=1000, height=860, margin=2).generate(text)
import matplotlib.pyplot as plt
plt.imshow(wordcloud)
rcParams['figure.figsize'] = 20, 10
plt.axis("off")
plt.show()
The snippet should generate a word cloud similar to the one given...