import pandas as pd
import time
print(“转化开始”)
t0 = time.clock()
excelname = “PREDICTEDDATA20216-8(1).xls”
sheet0 = pd.read_excel(excelname, sheet_name =0)
sheet1 = pd.read_excel(excelname, sheet_name =1)
SLAB_NO = sheet1[“SLAB_NO”]
sheet1IDdic = {}
for Sindex,Svalue in SLAB_NO.items():
if not pd.isnull(Svalue):
sheet1IDdic[int(Svalue)] = Sindex
print(sheet1IDdic)
hangshu = sheet0.iloc[:,0].size
for i in range(hangshu):
SLAB_NO_Value = sheet0.iloc[i, 0]
if not pd.isnull(SLAB_NO_Value):
if SLAB_NO_Value in sheet1IDdic:
sheet1Index = sheet1IDdic[SLAB_NO_Value]
# print(“SLAB_NO_Value”, SLAB_NO_Value)
sheet0.iloc[i, 4] = sheet1.iloc[sheet1Index, 1]
sheet0.iloc[i, 5] = sheet1.iloc[sheet1Index, 2]
sheet0.iloc[i, 6] = sheet1.iloc[sheet1Index, 3]
sheet0.iloc[i, 7] = sheet1.iloc[sheet1Index, 4]
filename = “new”
writer = pd.ExcelWriter(filename + ‘.xlsx’)
sheet0.to_excel(writer, index=False)#index=False,header=None)
writer.save()
writer.close()
print(“转化成功,耗时:”,time.clock() - t0)
#2110211445 2110211447 2110493234