# Filter a number when missing values are in column

**URL:** <https://discourse.julialang.org/t/filter-a-number-when-missing-values-are-in-column/76246>\
**Category:** New to Julia\
**Tags:** dataframes, missing-values\
**Created:** [February 11, 2022, 2:11pm UTC](https://discourse.julialang.org/t/filter-a-number-when-missing-values-are-in-column/76246 "2022-02-11T14:11:13Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![halleysfifthinc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/halleysfifthinc/32/206280_2.png) [@halleysfifthinc](https://discourse.julialang.org/u/halleysfifthinc)\
**Post date:** [February 11, 2022, 3:14pm UTC](https://discourse.julialang.org/t/filter-a-number-when-missing-values-are-in-column/76246/21 "2022-02-11T15:14:07Z")

</div>

Another solution that hasn’t been mentioned yet is to use `===` instead of `==` for comparisons.

```julia
julia> 5 == missing
missing

julia> 5 === missing
false

```

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [February 11, 2022, 3:30pm UTC](https://discourse.julialang.org/t/filter-a-number-when-missing-values-are-in-column/76246/22 "2022-02-11T15:30:53Z")

</div>

There are a lot of answers in this thread already that tell you how to do it, e.g.:

```julia
julia> df[coalesce.(df.a .!= 5, true), :]
4×2 DataFrame
 Row │ a b     
     │ Int64? Int64 
─────┼────────────────
   1 │ 3 1
   2 │ 6 3
   3 │ 0 4
   4 │ missing 5

```

or

```julia
julia> df[.!isequal.(df.a, 5), :]
4×2 DataFrame
 Row │ a b     
     │ Int64? Int64 
─────┼────────────────
   1 │ 3 1
   2 │ 6 3
   3 │ 0 4
   4 │ missing 5

```

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [February 11, 2022, 3:47pm UTC](https://discourse.julialang.org/t/filter-a-number-when-missing-values-are-in-column/76246/23 "2022-02-11T15:47:55Z")

</div>

OP, there is also the macro flag `@passmissing` in DataFramesMeta.jl which will help you work with `missings`, but it will not solve your exact problem in this thread.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 11, 2022, 7:15pm UTC](https://discourse.julialang.org/t/filter-a-number-when-missing-values-are-in-column/76246/24 "2022-02-11T19:15:57Z")

</div>

FWIW, using `findall()` seems to be more performant here:

```julia
df[findall(!isequal(5), df.a), :]  

```

[Previous page](https://discourse.julialang.org/t/filter-a-number-when-missing-values-are-in-column/76246.md?page=1)
