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.
18 lines
538 B
18 lines
538 B
5 months ago
|
import pandas as pd
|
||
|
from wordcloud import WordCloud
|
||
|
import matplotlib.pyplot as plt
|
||
|
|
||
|
# 假设已经从 Excel 表中读取数据并存入 DataFrame df
|
||
|
df = pd.read_excel('ai_danmaku_result.xlsx')
|
||
|
|
||
|
# 将弹幕内容合并为一个字符串
|
||
|
text = " ".join(df['弹幕内容'])
|
||
|
|
||
|
# 创建词云对象
|
||
|
wordcloud = WordCloud(width=800, height=400, background_color='white').generate(text)
|
||
|
|
||
|
# 使用 matplotlib 显示词云图
|
||
|
plt.figure(figsize=(10, 5))
|
||
|
plt.imshow(wordcloud, interpolation='bilinear')
|
||
|
plt.axis('off')
|
||
|
plt.show()
|