How can we replace missing
values with 0.0
for a column in a DataFrame
?
The other answers are pretty good all over. If you are a real speed junky, perhaps the following might be for you:
# prepare example
using DataFrames
df = DataFrame(A = 1.0:10.0, B = 2.0:2.0:20.0)
df[ df[:A] %2 .== 0, :B ] = NA
df[:B].data[df[:B].na] = 0.0 # put the 0.0 into NAs
df[:B] = df[:B].data # with no NAs might as well use array