Filter a number when missing values are in column

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

julia> 5 == missing
missing

julia> 5 === missing
false

1 Like

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

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> 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
4 Likes

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.

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

df[findall(!isequal(5), df.a), :]  
1 Like