From 777b21aa2f624994e1638f18a2b962a7f1a1b042 Mon Sep 17 00:00:00 2001 From: phmycqkit <656078035@qq.com> Date: Wed, 18 Sep 2024 20:04:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1AI=E6=8A=80=E6=9C=AF=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E6=96=B9=E9=9D=A2=E7=9A=84=E6=AF=8F=E7=A7=8D=E5=BC=B9?= =?UTF-8?q?=E5=B9=95=E6=95=B0=E9=87=8F=EF=BC=8C=E5=B9=B6=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E6=8E=92=E5=90=8D=E5=89=8D8=E7=9A=84?= =?UTF-8?q?=E5=BC=B9=E5=B9=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GetAI.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 GetAI.py diff --git a/GetAI.py b/GetAI.py new file mode 100644 index 0000000..aaafb6a --- /dev/null +++ b/GetAI.py @@ -0,0 +1,23 @@ +import pandas as pd + +def GetAI(): + # 读取CSV文件 + df = pd.read_csv('danmu.csv') + + # 筛选出第一列(弹幕)包含关键词"AI"的行 + ai_danmu = df[df['弹幕'].str.contains('AI', na=False)] + + # 将筛选后的数据保存为XLSX文件 + ai_danmu.to_excel('ai_danmu.xlsx', index=False) + + # 统计每个弹幕出现的次数 + ai_danmu_count = ai_danmu.groupby('弹幕')['数量'].sum().reset_index() + + # 找出出现次数最多的8个弹幕 + ai_danmu_most_common = ai_danmu_count.sort_values(by='数量', ascending=False).head(8) + + # 将这8个元素保存为XLSX文件 + ai_danmu_most_common.to_excel('ai_danmu_most_common.xlsx', index=False) + +if __name__ == '__main__': + GetAI() \ No newline at end of file