You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
678 B
Python
20 lines
678 B
Python
import pandas as pd
|
|
|
|
# 读取原始Excel文件
|
|
df = pd.read_excel('data/LeaveRecord.xlsx', sheet_name=None)
|
|
|
|
# 创建一个空的DataFrame来保存统计结果
|
|
result_df = pd.DataFrame(columns=['学号', '请假次数'])
|
|
|
|
# 遍历每个sheet
|
|
for sheet_name, sheet_data in df.items():
|
|
# 统计每个学生的请假次数
|
|
student_counts = sheet_data['学号'].value_counts().reset_index()
|
|
student_counts.columns = ['学号', '请假次数']
|
|
|
|
# 将统计结果添加到结果DataFrame中
|
|
result_df = pd.concat([result_df, student_counts], ignore_index=True)
|
|
|
|
# 保存结果DataFrame到新的Excel文件
|
|
result_df.to_excel('output_LR.xlsx', index=False)
|