You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
420 B

import matplotlib.pyplot as plt
from wordcloud import WordCloud
import jieba
# 读取弹幕数据
df = pd.read_excel('danmakus.xlsx')
# 生成词云
text = ' '.join(jieba.cut(' '.join(df['danmaku'])))
wordcloud = WordCloud(font_path='msyh.ttc', width=800, height=400).generate(text)
# 显示词云
plt.figure(figsize=(10, 5))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis('off')
plt.show()