计算接种率
#R 实现
inoc %>%
filter(str_sub(gldw_bm,1,2)=='62') %>%
mutate(yzyl=floor(day(as.period(interval(csrq,ymd('2021-01-25')),unit = "days"))/30)) %>%
filter(yzyl>=8 & yzyl<18) %>%
group_by(xian) %>%
summarise(deno=n_distinct(grda_et_lsh),num=sum(str_sub(ym_bm,1,2) %in% c('14') & jz_zc %in% c(1),na.rm = TRUE)) %>%
mutate(prec=round(num/deno*100,1)) %>%
left_join(xzqh,by=c('xian'='dzbm')) %>%
arrange(xian)
Python实现
(inoc
>>head(1000)
>>mutate(yzyl=((pd.to_datetime('2021-01-25')-_.csrq).dt.days/30),xian=_.gldw_bm.str[0:6])
>>filter(_.gldw_bm.str[0:2]=='62',_.yzyl>=8)
>>group_by(_.xian)
>>summarize(n=n_distinct(_.grda_code),n3=(((_.ym_bm.str[0:2]=='12') & (_.jz_zc==1)).sum(skipna=True)))
>>mutate(pert=np.round(_.n3/_.n*100,2))
>>arrange(_.xian)
)
评论
发表评论