我有一段R代码,我正试图弄清楚如何在Python中实现它。 它需要一个名为INDUST_CODE的列,并检查其值,以根据值的范围指定一个类别作为一个新列。请问我如何在python中执行类似操作
industry_index <- full_table_update %>%
mutate(industry = case_when(
INDUST_CODE < 1000 ~ 'Military_service',
INDUST_CODE < 1500 & INDUST_CODE >= 1000 ~ 'Public_service',
INDUST_CODE < 2000 & INDUST_CODE >= 1500 ~ 'Private_sector',
INDUST_CODE >= 2000 ~ 'Others'
)) %>%
select(industry)
您可以使用
pandas.cut
按照您的示例将其组织到存储箱中相关问题 更多 >
编程相关推荐