Currently, i have a dataframe contain words and weight (tf*idf) and i wanna show words which are arranged following weight in wordcloud.
Dataframe is on the left image.
def generate_wordcloud(words_tem):
word_cloud = WordCloud(width = 512, height = 512, background_color='white', stopwords= None, max_words=20).generate(words_tem)
plt.figure(figsize=(10,8),facecolor = 'white', edgecolor='blue')
plt.imshow(word_cloud, interpolation='bilinear')
plt.axis('off')
plt.tight_layout(pad=0)
plt.show()
tfidf = TfidfVectorizer(data, lowercase = False)
tfs = tfidf.fit_transform([data])
feature_names = tfidf.get_feature_names()
df = pd.DataFrame(tfs.T.toarray(), index=feature_names, columns= ['weight'])
df = df.sort_values(by = 'weight', ascending = False)
word_lists = df.index.values
unique_str = ' '.join(word_lists)
print(df[0:20])
generate_wordcloud(unique_str)
