# Which should I use, nothing or NA for DataFrames?

**URL:** https://discourse.julialang.org/t/which-should-i-use-nothing-or-na-for-dataframes/19056
**Category:** New to Julia
**Created:** [December 28, 2018, 9:04am UTC](https://discourse.julialang.org/t/which-should-i-use-nothing-or-na-for-dataframes/19056 "2018-12-28T09:04:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![krenova](https://avatars.discourse-cdn.com/v4/letter/k/53a042/32.png) [@krenova](https://discourse.julialang.org/u/krenova)
#### Post date: [December 28, 2018, 9:04am UTC](https://discourse.julialang.org/t/which-should-i-use-nothing-or-na-for-dataframes/19056/1 "2018-12-28T09:04:40Z")

</div>

I’m using Julia 1.0.3 and have loaded a csv file but found that the fields are not of the appropriate type.

Therefore, I’ve changed some columns of integer data type into strings, as an example

```julia
map(x -> ismissing(x) ? NA : convert(String, x), df[:Column1])

```

But when I tried to parse strings into Float64, and for the sake of consistency, change the default nothing into _NA_ using

```julia
map(x-> (v = tryparse(Float64,x); v == nothing ? NA : v), csv[:recency])

```

I get the error _UndefVarError: NA not defined_

However, if I stick to _nothing_, I feel uncomfortable know that my column is of type: Array{Union{Nothing, Float64},1}. A mix of 2 data types. I fear that the mixture of data types may lead to issues further down in my programme. At the same time, I am unable to change _nothing_ to _NA_.

Any advice?

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [December 28, 2018, 9:09am UTC](https://discourse.julialang.org/t/which-should-i-use-nothing-or-na-for-dataframes/19056/2 "2018-12-28T09:09:03Z")

</div>

Neither, use `missing`:  
[https://docs.julialang.org/en/v1/manual/missing/](https://docs.julialang.org/en/v1/manual/missing/)

> [@krenova](#):
>
> I fear that the mixture of data types may lead to issues further down in my programme

This is unwarranted, using small unions is now [supported](https://docs.julialang.org/en/v1/devdocs/isbitsunionarrays/).

---

<div class="post-metadata">

### Author: ![ValdarT](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/valdart/32/24146_2.png) [@ValdarT](https://discourse.julialang.org/u/ValdarT)
#### Post date: [December 28, 2018, 11:29am UTC](https://discourse.julialang.org/t/which-should-i-use-nothing-or-na-for-dataframes/19056/3 "2018-12-28T11:29:41Z")

</div>

There is also a very nice blog post for describing the reasoning behind `missing` in Julia: [First-Class Statistical Missing Values Support in Julia 0.7](https://julialang.org/blog/2018/06/missing)

---

<div class="post-metadata">

### Author: ![krenova](https://avatars.discourse-cdn.com/v4/letter/k/53a042/32.png) [@krenova](https://discourse.julialang.org/u/krenova)
#### Post date: [December 30, 2018, 10:06am UTC](https://discourse.julialang.org/t/which-should-i-use-nothing-or-na-for-dataframes/19056/4 "2018-12-30T10:06:50Z")

</div>

Thanks @Tamas_Papp, for direclty answering the question and also addressing the concern about in data type incompatibility.

---

<div class="post-metadata">

### Author: ![krenova](https://avatars.discourse-cdn.com/v4/letter/k/53a042/32.png) [@krenova](https://discourse.julialang.org/u/krenova)
#### Post date: [December 30, 2018, 10:07am UTC](https://discourse.julialang.org/t/which-should-i-use-nothing-or-na-for-dataframes/19056/5 "2018-12-30T10:07:00Z")

</div>

Thanks ValdarT, this is indeed a good summary. If anyone’s interested, some of the key points are that:

1.missing is analagous to NULL in sql and NA in R  
2. missing is similar to its predecessor NA (in Julia)  
3. makes it easy to generate sql requests in Julia and interoperate with R
