我有一个12M行的数据表,对于1列,我想修改TYPE字段。首先,我将其作为一个角色,然后修改文本。
第二个操作需要6秒,即数据帧版本需要多长时间
这是数据框版本:
df$TYPE = as.character(df$TYPE)
df$TYPE = ifelse( is.na(df$TYPE )== TRUE, "NONE", df$TYPE)
here is the data table code that takes just as long as the code above:
dt[, TYPE := as.character(TYPE) ]
dt[, TYPE := ifelse( is.na(TYPE )== TRUE, "NONE", TYPE)]
有没有办法加快速度?