image_output_1.png
from wordcloud import WordCloud, STOPWORDS

import re

import string

def clean_text(text):
    text = text.lower().strip()
    text = ' '.join([w for w in text.split() if len(w) > 2])
    text = re.sub('\\[.*?\\]', '', text)
    text = re.sub('https?://\\S+|www\\.\\S+', '', text)
    text = re.sub('<.*?>+', '', text)
    text = re.sub('[%s]' % re.escape(string.punctuation), '', text)
    text = re.sub('\n', '', text)
    text = re.sub('\\w*\\d\\w*', '', text)
    return text

train_word = train.explode('comment')

word_all_rate = train_word.comment.value_counts(ascending=True)

word_all_rate = word_all_rate[word_all_rate > 10]

text = word_all_rate.sort_values(ascending=False)

text = text[:100]

text = text.index.map(str)

listToStr = ' '.join(map(str, text.format()))

from wordcloud import WordCloud, STOPWORDS
wordcloud = WordCloud(width=3000, height=2000, random_state=1, background_color='salmon', colormap='Pastel1', collocations=False, stopwords=STOPWORDS).generate(listToStr)
plot_cloud(wordcloud)