简体   繁体   中英

How to create a wordcloud for a phrase not individual word in python

I'm trying to create wordcloud from a list that each name is a phrase but at final result each part shows separately and need to keep them as one element at wordcloud

after I plot this data frame each part of the word placed separately at the picture. How to keep each value together?`

df=['Jurassic park','Captain America','Universal Studios','Mad max']

text=df
title = WordCloud(width=1000,             height=500,background_color="white",max_words=10).generate(text)
plt.axis("off")
plt.imshow(title)
plt.show()

`

You can simply use a for loop to look through each item and do whatever you need to with the length of the words.

df=['Jurassic park','Captain America','Universal Studios','Mad max']

for name in df:
    print(len(name))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM