i have a csv file with 2 columns (dataframe) column 1 contains a sentence i love banana
and column 2 contains a classe i have 5 classes
i need a wordcloud for each class in fact each all the senetences corresponding to each classe it possible to do it ? it try this code but id does not working
import matplotlib.pyplot as plt
cloud = WordCloud(background_color="white", max_words=20, stopwords=stopwords)
tuples = tuple([tuple(x) for x in df.Phrase.value_counts().reset_index().values])
a = cloud.generate_from_frequencies(tuples)
plt.imshow(a)
plt.axis("off")
plt.title("a")
plt.show()
example of datasets
text classe
i love banana positive
i hate banana negetive
maybe i love maybe no neutral
bit yes bit no not_sure
wooooooooooow like_it
Here is an example for one class:
positive
.Assuming we have the following DF:
Solution:
Result:
Some explanations:
generated text for a single
class
: