# Collect a singleton query result as a dict with no missing values

**URL:** <https://discourse.julialang.org/t/collect-a-singleton-query-result-as-a-dict-with-no-missing-values/49157>\
**Category:** New to Julia\
**Tags:** question, query, dataframes\
**Created:** [October 28, 2020, 1:14am UTC](https://discourse.julialang.org/t/collect-a-singleton-query-result-as-a-dict-with-no-missing-values/49157 "2020-10-28T01:14:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Post date:** [October 28, 2020, 1:14am UTC](https://discourse.julialang.org/t/collect-a-singleton-query-result-as-a-dict-with-no-missing-values/49157/1 "2020-10-28T01:14:09Z")

</div>

How can I refactor the following queries so that the tests pass?

```julia
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:

```julia
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:

```julia
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:

```julia
dd = filter(v->!ismissing(v.second),Dict(Symbol.(names(d[1,:])).=>values(d[1,:])))

```
