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.
17 lines
718 B
Python
17 lines
718 B
Python
import pandas as pd
|
|
|
|
# 读取原始Excel文件的所有sheet
|
|
excel_file = pd.ExcelFile('data/LeaveRecord.xlsx')
|
|
df = pd.concat([excel_file.parse(sheet_name) for sheet_name in excel_file.sheet_names])
|
|
|
|
# 统计每个学生的请假次数和姓名
|
|
student_counts = df.groupby('学号').size().reset_index(name='请假次数')
|
|
student_names = df.groupby('学号')['姓名'].unique().reset_index()
|
|
student_counts['姓名'] = student_names['姓名'].apply(lambda x: ','.join(x))
|
|
|
|
# 判断是否错误
|
|
student_counts['是否错误'] = student_counts['姓名'].apply(lambda x: 1 if len(x.split(',')) > 1 else 0)
|
|
|
|
# 保存结果到新的Excel文件
|
|
student_counts.to_excel('data_processed/Leave_Record_RES.xlsx', index=False)
|