#将收入段转换成收入
imcome_map = {
1:[2000,3000],
2:[3000,3500],
3:[3500,6000],
4:[6000,8000],
5:[8000,10000],
6:[10000,15000]
}
def cal_income(income_segment,household_pop_num):
per_income = random.choice(imcome_map[income_segment]) #在对应的收入区间里面进行选择
h_income_all = per_income*household_pop_num
return h_income_all
choosers['imcome'] = choosers[['income_segment','household_pop_num']].apply(lambda x:cal_income(x['income_segment'],x['household_pop_num']),axis =1)
choosers
将收入段转换成收入
最新推荐文章于 2024-08-20 13:04:52 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)