![](/img/trans.png)
[英]i' m trying to display a wordcloud image but I'm getting ValueError: We need at least 1 word to plot a word cloud, got 0
[英]I'm trying to create a wordcloud with this python code, but keeps getting error
下面的代码是用 Jupyter notebook 的 python 编写的。
def create_word(text):
mask = np.array (Image.open("cloud.png"))
stopwords = set (STOPWORDS)
wc= WordCloud(background_color="white",
mask= mask,
max_words=3000,
stopwords=stopwords,
repeat=True)
wc.generate(str(text))
wc.to_file("wc.png")
print("Word Cloud Saved Successfully")
path="wc.png"
display(Image.open(path))
create_wordcloud(tw_list["text"].values)
这是产生的错误
<ipython-input-83-57370aac7740> in create_wordcloud(text)
3
4 def create_wordcloud(text):
----> 5 mask = np.array(Image.open("cloud.png"))
6 stopwords = set(STOPWORDS)
7 wc = WordCloud(background_color="white",
~\anaconda3\lib\site-packages\PIL\Image.py in open(fp, mode, formats)
FileNotFoundError: [Errno 2] No such file or directory: 'cloud.png'
从以下 GitHub https://github.com/yalinyener/TwitterSentimentAnalysis下载 cloud.png 和 wc.png 文件
然后上传到您的源位置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.