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