From af32927f5bb71c044cdae290f433e001c922c1af Mon Sep 17 00:00:00 2001 From: mxr612 Date: Wed, 4 Jun 2025 16:13:09 +0800 Subject: [PATCH] =?UTF-8?q?[Build=201.3.0]=20feat:=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=90=8E=E5=A4=87=E5=AD=A6=E5=8E=86=E5=A4=84=E7=90=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增一个后备函数用于处理学历字段,确保在缺失值情况下返回有效的学历信息 - 修改Excel输出逻辑,优先使用现学历字段,提升数据的完整性和准确性 --- main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 1628091..7e0917a 100644 --- a/main.py +++ b/main.py @@ -149,6 +149,12 @@ BaseData["工龄调增"] = BaseData["工龄调增"].apply(to_int) BaseData["工龄调减"] = BaseData["工龄调减"].apply(to_int) BaseData["学龄"] = BaseData["学龄"].apply(to_int) +def fallback(x): + for i in x: + if pd.notna(i) and i != '': + return i + return '' + max_promote = 0 max_history = 0 @@ -332,7 +338,7 @@ for index, row in BaseData.iterrows(): # 汇总 ws.cell(row=6+index, column=3, value=row["性别"]) ws.cell(row=6+index, column=4, value=format_time(row["出生年月"], "出生年月")) ws.cell(row=6+index, column=5, value=format_time(row["参加工作时间"], "参加工作时间")) - ws.cell(row=6+index, column=6, value=row["学历"]) + ws.cell(row=6+index, column=6, value=fallback([row["现学历"],row["学历"]])) ws.cell(row=6+index, column=7, value=nowtime.year-row["参加工作时间"].year+row["工龄调增"]-row["工龄调减"]+1+row["学龄"]) ws.cell(row=6+index, column=8, value=nowtime.year-row["参加工作时间"].year+row["工龄调增"]-row["工龄调减"]+1) ws.cell(row=6+index, column=9, value=row["学龄"])