有没有更优雅的方式来编写这段代码?我一遍又一遍地做同样的手术,所以感觉好像有,但我想不起来。
成人是熊猫数据框。权重是人的样本权重,每个 ped 变量代表不同的残疾类型。
total_cognitive_m = (adults.weight * (adults.pedisrem==1)).sum()/1e6
total_mobility_m = (adults.weight * (adults.pedisout==1)).sum()/1e6
total_self_care_m = (adults.weight * (adults.pedisdrs==1)).sum()/1e6
total_physical_m = (adults.weight * (adults.pedisphy==1)).sum()/1e6
total_vision_m = (adults.weight * (adults.pediseye==1)).sum()/1e6
total_hearing_m = (adults.weight* (adults.pedisear==1)).sum()/1e6
total_disabled_m = (adults.weight * adults.disabled).sum()/1e6
慕尼黑8549860
有只小跳蛙
一只甜甜圈
相关分类