'Printing word cloud for every unique value

I have a dataframe which contains a video_id value and comments from each videos which have been tokenized as seen below.

dataframe

I want to print a wordcloud for every comment matching a specific video_id.

For example, every comment where video_id == r2oPk20OHBE as one word cloud and so on.

for id in df_comments['video_id']:
  text = df_comments.loc[df_comments['video_id'] == id, 'tokenized_text'].values
  wordcloud = WordCloud().generate(str(text))

  plt.imshow(wordcloud)
  plt.axis("off")
  plt.show()

However, running this code creates a word cloud for every individual comment which results in WAY too many word clouds. How can I group the word clouds by their unique video_ids?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source