【发布时间】:2021-01-26 16:01:51
【问题描述】:
起初我以为问题出在我的数据上,我在清理数据时犯了一个错误。但是我检查了它,事实并非如此。
我正在使用此代码:
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
allWords = ' '.join([twts for twts in df['full_text']])
wordCloud = WordCloud(collocations=True, width = 1000,
height=600, random_state = 21, max_font_size = 120).generate(allWords)
plt.imshow(wordCloud, interpolation = "bilinear")
plt.axis('off')
plt.show()
现在我的 wordcloud 会显示诸如“coronaviru”、“viru”、“crisi”之类的词。使用collocations=True 它会显示完整的词以及其他词,例如“coronavirus case”“coronavirus 大流行”。
有谁知道如何解决这一问题?
就像我说的那样,我检查了数据,那里总是正确的完整单词。所以我猜这个错误发生在 wordcloud 上。
我的数据如下所示:
created_at id full_text
0 Sat Aug 01 00:25:53 +0000 2020 28934685093219 life is hard with coronavirus
1 Sat Aug 01 00:25:53 +0000 2020 28934685093219 coronavirus sucks
【问题讨论】:
-
发布您的数据样本
-
@gtomer 我添加了它。
标签: python pandas matplotlib word-cloud