-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new columns via transform and missing values #84
Comments
I think this is an upstream problem. Note the result type of the following: julia> 2*dd[:b]
3-element Array{Any,1}:
2
4
missing |
Note that I edited the example above. It's the same answer with |
You're right. This is much more pervasive than I thought. I'll post this in Missings.jl I suppose. julia> a=[1,missing,2]
3-element Array{Union{Int64, Missings.Missing},1}:
1
missing
2
julia> a+2
3-element Array{Any,1}:
3
missing
4 |
It's even more upstream than that, see JuliaLang/julia#25553. |
Until the upstream issue is resolved, I've written a workaround (that is admittedly quite slow). With simple arrays you can just convert to the correct type, but with dataframes that doesn't happen. What I do is, basically, you can do your operations which will return vectors of function anytounion!(d,x::Union{Integer,Symbol})
LL = length(d[x])
tmp = Vector{Union{Float64,Missing}}(LL)
@inbounds for i =1:LL
tmp[i] = d[i,x]
end
d[:,x] = tmp
return d
end Note that it isn't flexible (it always creates Just thought this might be helpful to anybody on 0.6 / finding this issue frustrating. |
Another workaround that's speedy is to preallocate the result.
Another option for preallocating is to use |
This is fixed on Julia 0.7 master branch, so I'm going to close the issue. |
I think perhaps
transform
from DataFramesMeta has some problems when the new column containsmissing
. When I do an operation involving a column of typeUnion{<:Real,Missing}
the new column will be of typeAny
rather thanUnion{<:Real,Missing}
The text was updated successfully, but these errors were encountered: