Excel
VLOOKUP函数
=VLOOKUP(A2,Scores!A2:B21,2,0)#不做近似填充
pandas
merge函数
方法一
students=pd.read_excel('016/Student_Score.xlsx',sheet_name='Students')
scores=pd.read_excel('016/Student_Score.xlsx',sheet_name='Scores')
table=students.merge(scores,on='ID')
print(table)
方法二
如果!!ID设为索引后会从普通列中消失
students=pd.read_excel('016/Student_Score.xlsx',sheet_name='Students',index_col='ID')
scores=pd.read_excel('016/Student_Score.xlsx',sheet_name='Scores',index_col='ID')
table=students.merge(scores,how='left',left_on=students.index,right_on=scores.index).fillna(0)
table.Score=table.Score.astype(int)
默认状态,在scores中查