# How to filter out rows with NaN in specific fields?

**URL:** <https://discourse.julialang.org/t/how-to-filter-out-rows-with-nan-in-specific-fields/30250>\
**Category:** New to Julia\
**Tags:** dataframes\
**Created:** [October 23, 2019, 10:50pm UTC](https://discourse.julialang.org/t/how-to-filter-out-rows-with-nan-in-specific-fields/30250 "2019-10-23T22:50:05Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ElOceanografo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eloceanografo/32/624_2.png) [@ElOceanografo](https://discourse.julialang.org/u/ElOceanografo)\
**Post date:** [October 24, 2019, 12:04am UTC](https://discourse.julialang.org/t/how-to-filter-out-rows-with-nan-in-specific-fields/30250/2 "2019-10-24T00:04:24Z")

</div>

You’re looking for `isnan`:

```julia
using DataFrames
x = randn(10)
x[5] = NaN
df = DataFrame(x=x)

filter(row -> ! isnan(row.x), df)

```

Or, using DataFramesMeta,

```julia
using DataFramesMeta
@where(df, .! isnan.(:x))
@linq df |> where(.! isnan.(:x))

```

In Julia, `missing` is the equivalent of R’s `NA`, and is used for any value which exist in theory but are not available or weren’t measured. In contrast `NaN` (not-a-number) only exists for Floats. For most data analysis, `missing` is more generic and will be easier to work with in Julia–depending on your workflow, it might make sense to convert `NaN`s to `missing`s first.

(For more than you (probably) want to know on this topic, please [this blog post](https://julialang.org/blog/2018/06/missing) and this [Discourse discussion](https://discourse.julialang.org/t/missing-or-nan/12729)… 🙃)

---

_[View the full topic](https://discourse.julialang.org/t/how-to-filter-out-rows-with-nan-in-specific-fields/30250)._
