round(1)保留1位小数
# 三列求平均值,并保留1位小数
x['score_avg'] = x[['score_201801', 'score_201802', 'score_201803']] \
.apply(lambda x: x.mean(), axis=1).round(1)
mean()可以跳过空值。比如3列求平均值,有一列为空,则两列不为空的和,除以2
# 两列求差,x['score_201804'] - x['score_avg']
x['score_delta'] = x['score_201804'].sub(x['score_avg'])