From 756e5178b5db535fc214c671cbc40d5417c69e50 Mon Sep 17 00:00:00 2001 From: pzb7h6yxf <1736289433@qq.com> Date: Tue, 17 Sep 2024 15:22:45 +0800 Subject: [PATCH] Delete '2.2.2.py' --- 2.2.2.py | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 2.2.2.py diff --git a/2.2.2.py b/2.2.2.py deleted file mode 100644 index 98d80af..0000000 --- a/2.2.2.py +++ /dev/null @@ -1,41 +0,0 @@ -import jieba -import wordcloud -import imageio -import pandas as pd # 用于读取Excel文件 - -# 读取图片作为词云的形状 -img = imageio.imread('四叶草1.png') - -# 使用pandas读取Excel文件中的所有列 -df = pd.read_excel('top_ai_danmakus.xlsx') - -# 将Excel所有列的数据拼接成一个长字符串 -book = '' - -# 遍历每一列并将内容合并成字符串 -for column in df.columns: - # 将当前列转换为字符串并拼接到 book 变量 - book += ' '.join(df[column].astype(str)) + ' ' - -# 使用jieba进行分词 -book_list = jieba.lcut(book) -book_str = ' '.join(book_list) - -# 打印分词后的字符串 -print(book_str) - -# 创建词云 -wc = wordcloud.WordCloud( - width=500, - height=500, - background_color='white', - mask=img, - stopwords={'main','Taipei','afraid','aiden','Britain'}, # 可添加不需要的停用词 - font_path='msyh.ttc' # 设置中文字体路径 -) - -# 生成词云 -wc.generate(book_str) - -# 保存词云图 -wc.to_file('词云图.png')