我正试图在我的数据框架中根据观察结果的相应SIC代码(变量:'sich')使用行业分类(变量:industry)精确地获得一个额外的列。我得到错误“ValueError:序列的真值不明确。请使用a.empty、a.bool()、a.item()、a.any()或a.all()”。如果我将“and”改为“&;”它给出了“TypeError:无法使用dtyped[float64]数组和[bool]类型的标量执行'rand_u2;'”,此时我正在尝试执行以下代码:
#industry classification based on SIC code
if comp_funda['sich'] >= 1000 and comp_funda['sich'] < 1300:
comp_funda['industry']=1
elif comp_funda['sich'] > 1399 and comp_funda['sich'] < 2000:
comp_funda['industry']=1
elif comp_funda['sich'] >= 2000 and comp_funda['sich'] <= 2111:
comp_funda['industry']=2
elif comp_funda['sich'] >= 2200 and comp_funda['sich'] <= 2780:
comp_funda['industry']=3
elif comp_funda['sich'] >= 2800 and comp_funda['sich'] <= 2824:
comp_funda['industry']=4
elif comp_funda['sich'] >= 2840 and comp_funda['sich'] <= 2899:
comp_funda['industry']=4
elif comp_funda['sich'] >= 2830 and comp_funda['sich'] <= 2836:
comp_funda['industry']=5
elif comp_funda['sich'] >= 2900 and comp_funda['sich'] <= 2999:
comp_funda['industry']=6
elif comp_funda['sich'] >= 1300 and comp_funda['sich'] <= 1399:
comp_funda['industry']=6
elif comp_funda['sich'] >= 3000 and comp_funda['sich'] < 3570:
comp_funda['industry']=7
elif comp_funda['sich'] > 3579 and comp_funda['sich'] < 3670:
comp_funda['industry']=7
elif comp_funda['sich'] > 3679 and comp_funda['sich'] <= 3999:
comp_funda['industry']=7
elif comp_funda['sich'] >= 7370 and comp_funda['sich'] <= 7379:
comp_funda['industry']=8
elif comp_funda['sich'] >= 3570 and comp_funda['sich'] <= 3579:
comp_funda['industry']=8
elif comp_funda['sich'] >= 3670 and comp_funda['sich'] <= 3679:
comp_funda['industry']=8
elif comp_funda['sich'] >= 4000 and comp_funda['sich'] <= 4899:
comp_funda['industry']=9
elif comp_funda['sich'] >= 4900 and comp_funda['sich'] <= 4999:
comp_funda['industry']=10
elif comp_funda['sich'] >= 5000 and comp_funda['sich'] <= 5999:
comp_funda['industry']=11
elif comp_funda['sich'] >= 7000 and comp_funda['sich'] < 7370:
comp_funda['industry']=12
elif comp_funda['sich'] > 7379 and comp_funda['sich'] <= 8999:
comp_funda['industry']=12
非常感谢您对解决此问题的任何帮助!提前非常感谢大家, 卢卡
目前没有回答
相关问题 更多 >
编程相关推荐