I have this code in R
where I am using data.table
, and I have the intention to translate it into Python
with datatable
. It creates columns with the value of each existing column divided by the mean of the total. Kind of normalization.
dataset[ , paste0( cols, suffix) := lapply( .SD, function(x){ x/mean(x, na.rm=TRUE)} ),
by= col_A,
.SDcols= cols]