How can I refactor the following queries so that the tests pass?
df = DataFrame(:a=>[1,2],:b=>["a","b"],:c=>[1,missing])
2×3 DataFrame
│ Row │ a │ b │ c │
│ │ Int64 │ String │ Int64? │
├─────┼───────┼────────┼─────────┤
│ 1 │ 1 │ a │ 1 │
│ 2 │ 2 │ b │ missing │
query 1:
d = @from i in df begin
@where (i.a,i.b) == (1,"a")
@select i
@collect Dict
end
@test d = Dict(:a=>1,:b=>"a",:c=>1)
fails
query 2:
d = @from i in df begin
@where (i.a,i.b) == (2,"b")
@select i
@collect Dict
end
@test d = Dict(:a=>2,:b=>"b")
fails
—edit—
I would prefer to avoid the following because it defeats the purpose of the more readable query syntax proposed above:
dd = filter(v->!ismissing(v.second),Dict(Symbol.(names(d[1,:])).=>values(d[1,:])))