# Difference between \`Union{Missing, Float64}\` and \`Float64?\`

**URL:** <https://discourse.julialang.org/t/difference-between-union-missing-float64-and-float64/57542>\
**Category:** New to Julia\
**Tags:** dataframes\
**Created:** [March 19, 2021, 2:20pm UTC](https://discourse.julialang.org/t/difference-between-union-missing-float64-and-float64/57542 "2021-03-19T14:20:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alessio](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@alessio](https://discourse.julialang.org/u/alessio)\
**Post date:** [March 19, 2021, 2:20pm UTC](https://discourse.julialang.org/t/difference-between-union-missing-float64-and-float64/57542/1 "2021-03-19T14:20:06Z")

</div>

I have a DataFrame that was created by importing a CSV. Then I applied several transformations. Now when I run `describe` on it I get some columns that report `Union{Missing, Float64}` as type and others report `Float64?`.

What is the difference? Both columns have `Float64` type and contain `missing` values.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [March 19, 2021, 2:23pm UTC](https://discourse.julialang.org/t/difference-between-union-missing-float64-and-float64/57542/2 "2021-03-19T14:23:59Z")

</div>

you can’t possibly have `missing` values in the `Float64` column. But you certainly can have columns of `Union{Missing, Float64}` but really no longer have any `missing`s, in which case you can use:  
[disallowmissing!](https://dataframes.juliadata.org/stable/lib/functions/#DataFrames.disallowmissing!)

---

<div class="post-metadata">

**Author:** ![alessio](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@alessio](https://discourse.julialang.org/u/alessio)\
**Post date:** [March 19, 2021, 2:30pm UTC](https://discourse.julialang.org/t/difference-between-union-missing-float64-and-float64/57542/3 "2021-03-19T14:30:25Z")

</div>

The column type is `Float64?` with the question mark at the end.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [March 19, 2021, 2:31pm UTC](https://discourse.julialang.org/t/difference-between-union-missing-float64-and-float64/57542/4 "2021-03-19T14:31:11Z")

</div>

if you see a `T?` with a question mark that means `Union{Missing, T}`. As described in the Getting Started section of docs: [Getting Started · DataFrames.jl](https://dataframes.juliadata.org/stable/man/getting_started/#Examining-the-Data)

---

<div class="post-metadata">

**Author:** ![alessio](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@alessio](https://discourse.julialang.org/u/alessio)\
**Post date:** [March 19, 2021, 2:34pm UTC](https://discourse.julialang.org/t/difference-between-union-missing-float64-and-float64/57542/5 "2021-03-19T14:34:33Z")

</div>

Ok, so they are the same.  
It’s confusing that two number columns that contain missing values are marked one as `Union{Missing, Float64}` and the other column as `Float64?`

---

<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:** [March 19, 2021, 5:56pm UTC](https://discourse.julialang.org/t/difference-between-union-missing-float64-and-float64/57542/6 "2021-03-19T17:56:51Z")

</div>

That does sound strange, where is this happening? In the REPL I see:

```julia
julia> df = DataFrame(rand([missing; 1.0:10.0], 10, 10), :auto)
10×10 DataFrame
 Row │ x1 x2 x3 x4 x5 x6 x7 x8 x9 x10      
     │ Float64? Float64? Float64? Float64? Float64? Float64? Float64? Float64? Float64? Float64? 
─────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────
   1 │ 8.0 7.0 1.0 8.0 3.0 3.0 1.0 missing 3.0 9.0

```

---

<div class="post-metadata">

**Author:** ![alessio](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@alessio](https://discourse.julialang.org/u/alessio)\
**Post date:** [March 20, 2021, 11:45am UTC](https://discourse.julialang.org/t/difference-between-union-missing-float64-and-float64/57542/7 "2021-03-20T11:45:10Z")

</div>

Good question.  
I had some time today to investigate and came up with the following conclusion: **it’s just a matter of display real estate**.  
If the column name is short, then there would not be enough space to fit the `Union{...}` header

```julia
julia> DataFrame(a = [1,2,3,missing])
4×1 DataFrame
│ Row │ a │
│ │ Int64? │
├─────┼─────────┤
│ 1 │ 1 │
│ 2 │ 2 │
│ 3 │ 3 │
│ 4 │ missing │

```

However, if the column name is long enough, then the `Union{...}` type name representation would fit and so would be used:

```julia
julia> DataFrame(a12345678912345678901 = [1,2,3,missing])
4×1 DataFrame
│ Row │ a12345678912345678901 │
│ │ Union{Missing, Int64} │
├─────┼───────────────────────┤
│ 1 │ 1 │
│ 2 │ 2 │
│ 3 │ 3 │
│ 4 │ missing │

```
