Hi! I was trying trying to change all missing and NaN values into 0.
Firstly, created a dataframe
using DataFrames df_i = DataFrame( id =[101, 102, 103, 104, 105], name = ["A", "B", "C", NaN, "E"], age = [28, 32, missing, NaN, 31], salary = [3200, 3200, 4500, missing, missing] )
Then tried a loop for replacing missing and NaN values, which was:
col = names(df_i); for i in 1:length(col) replace!(df_i.col[i], missing => 0) replace!(df_i.col[i], NaN => 0) end
Well, the arguement did not go well, hence error was inevitable.
In this context, I actually need 2 things to know:
i) Is there any way to replace missing, NaN, and any specific value, whole across the dataframe? If so, how?
ii) In my looping, what went wrong?