Problems about dealing with missing values, maybe connected to DataFrames.jl

question

#1
julia> a=DataFrame([1 2 3; 4 missing 6])
2×3 DataFrame
│ Row │ x1     │ x2      │ x3     │
│     │ Int64⍰ │ Int64⍰  │ Int64⍰ │
├─────┼────────┼─────────┼────────┤
│ 1   │ 1      │ 2       │ 3      │
│ 2   │ 4      │ missing │ 6      │

julia> dropmissing!(a)
1×3 DataFrame
│ Row │ x1     │ x2     │ x3     │
│     │ Int64⍰ │ Int64⍰ │ Int64⍰ │
├─────┼────────┼────────┼────────┤
│ 1   │ 1      │ 2      │ 3      │

julia> a
1×3 DataFrame
│ Row │ x1     │ x2     │ x3     │
│     │ Int64⍰ │ Int64⍰ │ Int64⍰ │
├─────┼────────┼────────┼────────┤
│ 1   │ 1      │ 2      │ 3      │

julia> a[:2]
1-element Array{Union{Missing, Int64},1}:
 2


it still shows Union{Missing,…} after dropmissing!()

so I can’t put it into most other functions, they cause errors because they aren’t considered to take such array types including missing values.

i wonder how i can solve this problem, the function copy() doesn’t seem to be the answer…


#2
julia> Int.(a[2])
1-element Array{Int64,1}:
 2

#3

DataFrame([ Array{Int}(a[i]) for i=1:size(a,2)])


#4

You can do what you want with a above with disallowmissing! function:

julia> a |> dropmissing! |> disallowmissing!
1×3 DataFrame
│ Row │ x1    │ x2    │ x3    │
│     │ Int64 │ Int64 │ Int64 │
├─────┼───────┼───────┼───────┤
│ 1   │ 1     │ 2     │ 3     │

#5

See: