Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jupyter notebook:Wordcloud can't generate a word cloud #34

Open
ShuaiXiaoxi opened this issue May 17, 2024 · 1 comment
Open

Jupyter notebook:Wordcloud can't generate a word cloud #34

ShuaiXiaoxi opened this issue May 17, 2024 · 1 comment

Comments

@ShuaiXiaoxi
Copy link

Hey,
I am using Jupyter notebook to create a word cloud, but I'm encountering some issues that I can't resolve. I've tried various methods online, but I'm still stuck.。

`ValueError Traceback (most recent call last)
in
31 index_positive = data['scores'] >= 30.0
32
---> 33 my_word_cloud(data['content'][index_negative],stoplist,'aixin.jpg') # 差评词云
34 my_word_cloud(data['content'][index_positive],stoplist,'aixin.jpg') # 好评词云

in my_word_cloud(data, stoplist, img)
16 )
17 # 词云绘制
---> 18 wc.fit_words(wordFre)
19 plt.imshow(wc) # 词云
20 plt.axis('off') # 关闭坐标

C:\anaconda\lib\site-packages\wordcloud\wordcloud.py in fit_words(self, frequencies)
380 self
381 """
--> 382 return self.generate_from_frequencies(frequencies)
383
384 def generate_from_frequencies(self, frequencies, max_font_size=None): # noqa: C901

C:\anaconda\lib\site-packages\wordcloud\wordcloud.py in generate_from_frequencies(self, frequencies, max_font_size)
401 frequencies = sorted(frequencies.items(), key=itemgetter(1), reverse=True)
402 if len(frequencies) <= 0:
--> 403 raise ValueError("We need at least 1 word to plot a word cloud, "
404 "got %d." % len(frequencies))
405 frequencies = frequencies[:self.max_words]

ValueError: We need at least 1 word to plot a word cloud, got 0.`

@ShuaiXiaoxi
Copy link
Author

I'm using Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant