Here is a simple statement:
full_frl_college[:jun_sen] = Float64(full_frl_college[:jun_sen])
Here is the resulting error message:
LoadError: MethodError: `convert` has no method matching
convert(::Type{Float64}, ::DataArrays.DataArray{Int64,1})
What is the right approach to this conversion? I tried
convert(DataArrays.DataArray{Float64,1}, full_frl_college[:jun_sen])
which did not work.
Answering my own question, both of these work:
x = Array{Float64,1}(collect(full_frl_college[exist, :jun_sen]))
# or
full_frl_college[:jun_sen]=Array{Float64,1}full_frl_college[:jun_sen]
# note the collect() above is NOT needed
So, all is good.
My confusion was taking the error message too literally and trying to
convert using the DataArray type. Does the DataArrays.DataArray type
enable DataFrames to do its NA handling? If so, then I'd really want to use
that type rather than Array{Float64, N}. For this data, I'd already purged
the NAs so it didn't matter.
Obviously, dimensionality is part of the type of the starting and target
types. Perhaps that is a bit too restrictive. Is it possible that if a
conversion will be, in effect, an element-wise conversion of the entire
contents of the array that the conversion/promotion should be allowed? I
realize that with mixed types it can be unclear what a conversion "means".
But, when the object is already of one type and the target is of one type
it seems intuitive to just do the conversion even if the types, strictly
speaking, don't match because of dimensionality. I guess this is a request
for "element-wise" conversion.
Seems like this would make Julia more approachable. Also, it could make
the job of package developers, working with arrays and matrices, a bit
easier because they wouldn't need methods for as many cases.