# Nothings to Missings, Any to Float with Passmissing and Parse

**URL:** <https://discourse.julialang.org/t/nothings-to-missings-any-to-float-with-passmissing-and-parse/92487>\
**Category:** New to Julia\
**Created:** [January 4, 2023, 8:21am UTC](https://discourse.julialang.org/t/nothings-to-missings-any-to-float-with-passmissing-and-parse/92487 "2023-01-04T08:21:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Billpete002](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/billpete002/32/35091_2.png) [@Billpete002](https://discourse.julialang.org/u/Billpete002)\
**Post date:** [January 4, 2023, 8:21am UTC](https://discourse.julialang.org/t/nothings-to-missings-any-to-float-with-passmissing-and-parse/92487/1 "2023-01-04T08:21:44Z")

</div>

Hi,

I have been stumped on how to convert a `Any` with `nothing` to a `Float64` with `missing`.

The data I am importing from BigQuery using gbq\_query. The returned NULLS are as blank.

![image](https://global.discourse-cdn.com/julialang/original/3X/7/c/7c77b372b0c7f497c1f50e652e42ed8b62b6b2b5.png)

I try the normal passmissing parse method:

```julia
df_transformed = @chain df_raw begin
    @transform(
        :avg_theoretical_mrr = passmissing(parse).(Float64, :avg_theoretical_mrr)
        )
    end

```

but get the error:

`ERROR: MethodError: no method matching parse(::Type{Float64}, ::Nothing)`

Since `nothing` is not `missing`

I figured I would replace nothing with missing:

`df_transformed.avg_theoretical_mrr = replace.(df_transformed.avg_theoretical_mrr, nothing => missing)`

but get the error:  
`ERROR: MethodError: no method matching similar(::Missing, ::Type{Any})`

I even tried to switch these to strings but this merely switched nothing to “nothing” and it won’t allow me to replace “nothing” with missing in a string… 😂

But here is the question: is there an easy way to take type Any with blanks and convert them to Floats with missing succinctly?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [January 4, 2023, 8:51am UTC](https://discourse.julialang.org/t/nothings-to-missings-any-to-float-with-passmissing-and-parse/92487/2 "2023-01-04T08:51:28Z")

</div>

Try `something.(data, missing)`, this should return `missing` if a value is `nothing` and the value otherwise, and the result should be properly contained in a `Vector{Union{Float64, Nothing}}` because of the broadcasting operation.

---

<div class="post-metadata">

**Author:** ![Billpete002](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/billpete002/32/35091_2.png) [@Billpete002](https://discourse.julialang.org/u/Billpete002)\
**Post date:** [January 4, 2023, 9:50am UTC](https://discourse.julialang.org/t/nothings-to-missings-any-to-float-with-passmissing-and-parse/92487/3 "2023-01-04T09:50:26Z")

</div>

Would have never thought to use `something` 🙌  
Thanks!
