How to create a wordcloud and what is it helpful for?
Wordcloud is nothing but a data visualization technique mainly used for text representation it is also called a tag cloud. In this, the size of each word indicates its frequency or importance of that word. It displays a list of words, the importance of each is shown by font color or size.
What is it useful for: Analyzing text data from social media websites. Significant textual points can be highlighted using a word cloud. In a Customer service process useful to analyze customer feedback. Identifying new SEO(Search engine optimization) Keyword to target. And Many More...
!pip install wordcloud
from wordcloud import WordCloud, STOPWORDS
import matplotlib.pyplot as plt
import pandas as pd
df_sample = pd.read_csv('/content/Youtube_Comments_data.csv', encoding ="latin-1")
For sample data we are using youtube comments data on videos of famous artist.
words_comments = ''
My_stopwords = set(STOPWORDS)
for elements in df_sample.CONTENT:
elements = str(elements)
tokenization = elements.split()
for i in range(len(tokenization)):
tokenization[i] = tokenization[i].lower()
words_comments = words_comments + " ".join(tokenization)+" "
Here in the above in first for loop we are firstly typecasting the each element into string then splitting the values. After that in the second for loop we are converting each value into lower case.
My_wordcloud = WordCloud(width = 800, height = 800, background_color ='white', stopwords = My_stopwords, min_font_size = 10).generate(words_comments)
plt.figure(figsize = (8, 8), facecolor = None)
plt.tight_layout(pad = 0)