2022时政热点事件,2022最新时事新闻热点汇总
2022-11-13
更新时间:2022-12-15 09:50:57作者:自考头条
importpandasaspdfromopenpyxlimportload _ workbookdefget _ and _ save _ data _ new ( file _ path ) &; #039; &; #039; 只要重命名文件,就可以自动处理所有操作。数据保存工作簿包括:完整类、1-8类、9类、完整类描述分析&; #039; &; #039; &; #039; # step0)数据表列名准备base_col=[&; #039; 分类&; #039;&; #039; 类&; #039;&; #039; 名称&; #039;&; #039; 国语&; #039;&; #039; 数学&; #039;&; #039; 英语&; #039; 的总分data _ col=PD.read _ excel ( file _ path,sheet_name=&; #039; 数据&; #039; ).columns.to list ( data _ col=sorted ) )列表) *即使列表变重后,也要按照以前列表的顺序使用df=PD.read_excel(file_path )的方法#039; 数据&; #039; ) [data_col]df[ (总分&; #039; ) df.sum ( axx col ) )。 numeric_only=True ) #计算每个人的总分# step3:等级forsubjindf.columns [ df.columns.to list ( ).index(&;); #039; 国语&; #039; ) )到df列名称. index(subj ) 1df.insert ) insert_col,subj&; #039; 等级),df[subj].rank ) method=&; #039; dense&; #039;axis=0) ) # step4) ) ) step 0.8 ) ).round(2)2) )对所有等级进行描述分析,b为40%的成绩b _ pluss=describe.) #039; 40%,&; #039; 国语&; #039;2 ) )对应,提取各科及总等级b的分数#prinning的b_pluss_value(:&; #039; &; #039; &; #039; 判定b&; #039; &; #039; &; #039; if score=b _ pluss _ value:return & amp; #039; b&; #039; else:return&; #039; &; #039; #调用将b级别添加到工作表forsubjinb_plue的args=(b_pluss[subj],) )函数时,第二个参数是元组insert _ col=df.columns . #039; 分班&; #039; ]==9)准备将#9组数据分开添加到#工作簿,在新工作表中保存writer=PD.excel writer ( path=file _ PAA ter ) engine=&; #039; openpyxl&; #039; ) book=load _ workbook ( filename=file _ path ) writer.book=bookdf.to_excel ) writer,shook index=False(#保存#039; 1-8级成绩&; #039;index=false )保存1-8班学生数据clame index=false(#9班学生数据describe.to_excel(writer,sheet_name=&; #039; 所有级别describe分析&; #039;index=false(#保存的describe分析数据writer.save ) ( writer.close ) ) print )…成绩单分析整理完成…) ) return B_pluss # )各科及总分bdefmm #039; &; #039; &; #039; file_path=r&; #039; \\192.168.1.249\临时档案\04教师\XX\创新班资料\全级历史成绩/【第10周】2022-2023学年上学期第1期测试成绩统计