I have a dataframe which contains `NA` and float values. I would like to 
change the datatype of one of its columns from `Any` to `Float64`. The 
solution I found on the web

df[:x] = float64(df[:x])

yields a deprecation warning to use `map(Float64, df[:x])` and a conversion 
error. The map solution doesn't work either, since of course Float64(NA) 
isn't defined. I tried working directly with DataArrays, but the docs 
<https://github.com/JuliaStats/DataArrays.jl> are pretty sparse about how 
to work with them. Their example works:

da = @data([1, 2, NA, 4])


but merely entering

x = [1, 2, NA, 4]

yields a conversion error during `vcat` (hence the macro, presumably). So 
how may I convert a DataArray{Any} to DataArray{Float64}? This yields a 
conversion error (it works without the NA):

convert(DataArray{Float64}, Any[NA, 1,2,3])

And the macro doesn't work with comprehensions:

da = @data([isodd(x) ? NA : x for x in 1:10])

Did I miss anything?

Cédric

Reply via email to