博文

目前显示的是 五月, 2024的博文

R json解析

 library(jsonlite) ch1 <- fromJSON('/mnt/c/Users/xuefliang/Desktop/622921201605302722(1).txt') ch2 <- fromJSON('/mnt/c/Users/xuefliang/Desktop/622927202110102510(1).txt') ch3 <- fromJSON('/mnt/c/Users/xuefliang/Desktop/622921202303047214(1).txt') ch4 <- fromJSON('/mnt/c/Users/xuefliang/Desktop/622921202403302112(1).txt') ch5 <- fromJSON('/mnt/c/Users/xuefliang/Desktop/622921202403011825(1).txt') person1 <- as_tibble(ch1$data$PersonInfoList) person2 <- as_tibble(ch2$data$PersonInfoList) person3 <- as_tibble(ch3$data$PersonInfoList) person4 <- as_tibble(ch4$data$PersonInfoList) person5 <- as_tibble(ch5$data$PersonInfoList) person <- bind_rows(person1,person2,person3,person4,person5) vaccination <- person %>%   unnest(VaccinationInfoList) %>%    mutate(EntryDate=ymd_hms(EntryDate),UpdateDate=ymd_hms(UpdateDate),UplodeDate=ymd_hms(UplodeDate)) %>%    mutate(scjs = case_when(     difftime(UplodeDate, EntryD

按疫苗类别接种剂次排序后重新赋值

    def hbv ( self ):         df = self . _df         df .query( "vaccination_code in ['0201', '0202', '0203']" , inplace = True )         df [ 'vaccine_name' ] = '乙肝疫苗'         df = df .groupby( 'id_x' , group_keys = False ).apply(             lambda x : x .sort_values( by = 'vaccination_date' , ascending = True )             .assign( jc = range ( 1 , len ( x ) + 1 ))             .reset_index( drop = True )         )         return df bind_rows(jzjl,jzjl2) %>% mutate(mc = if_else(mc %in% c('麻腮风疫苗', '麻风疫苗'), '含麻疹成分疫苗', mc)) %>% filter(mc=='含麻疹成分疫苗') %>% group_by(grda_code) %>% arrange(jz_sj) %>% mutate(jz_zc = row_number()) ->tmp1