[英]how to remove custom words from word cloud in jupyter notebook
wordcloud = WordCloud(background_color="white",width=1600,height=800).generate(' '.join(df1['text'].tolist()))
plt.figure(figsize=(20,10), facecolor='k')
plt.imshow(wordcloud)
The word cloud that gets shown has data that I don't think is relevant, such as user, need, anyone, issue, trying, and some other words.显示的词云包含我认为不相关的数据,例如用户、需要、任何人、问题、尝试和其他一些词。 I have already removed stop words, but how can I remove a custom list of words from the word cloud?
我已经删除了停用词,但是如何从词云中删除自定义的词列表? This is a word cloud from data I scraped from slack, and I want it to representative of questions people are asking in the channel that are more related to things like email, server, outlook, duo etc.
这是我从 slack 中抓取的数据中的词云,我希望它能够代表人们在频道中提出的与电子邮件、服务器、Outlook、二重奏等更相关的问题。
You can do it like this:你可以这样做:
w = WordCloud()
stop_words = list(w.stopwords)
custom_stop_words = ['user', 'need']
stop_words = set(stop_words + custom_stop_words)
wordcloud = WordCloud(background_color="white",width=1600,height=800, stopwords=stop_words).generate(' '.join(df1['text'].tolist()))
plt.figure(figsize=(20,10), facecolor='k')
plt.imshow(wordcloud)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.