【发布时间】:2022-01-26 16:11:35
【问题描述】:
我正在尝试在 python 中使用 matplotlib 做一个词云,而不是像“will”这样计算单个单词,而是像“i will”那样计算两个单词。我查看了 word cloud 文档,似乎没有任何东西会产生这种情况,我的输入会导致这种情况吗?
我的代码如下所示:
fields = ['comments']
text= pd.read_csv('comments.csv', usecols=fields)
stopwords = ["https", "RT"] + list(STOPWORDS)
print(' '.join(text['comments'].tolist()))
wordcloud = WordCloud(stopwords=stopwords, background_color="white").generate(' '.join(text['comments'].tolist()))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
plt.show()
【问题讨论】:
标签: python dataframe matplotlib