# Julia convert 1-element Array to Integer

**URL:** <https://discourse.julialang.org/t/julia-convert-1-element-array-to-integer/23805>\
**Category:** New to Julia\
**Tags:** question, arrays, convert\
**Created:** [May 3, 2019, 9:04am UTC](https://discourse.julialang.org/t/julia-convert-1-element-array-to-integer/23805 "2019-05-03T09:04:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [May 3, 2019, 9:04am UTC](https://discourse.julialang.org/t/julia-convert-1-element-array-to-integer/23805/1 "2019-05-03T09:04:08Z")

</div>

Dear all,  
I am extracting a number from a dataframe’s column and I need to to math with it. The number I extract lokks like this:

```julia
julia> x = sub_qry[:Column]
1-element Array{Union{Missing, Int64},1}:
 107772

```

I have another variable:

```julia
julia> y
74

```

if I perform the calculation I need I obtain:

```julia
julia> z=len/sub_qry[:Column]
1×1 LinearAlgebra.Adjoint{Float64,Array{Float64,1}}:
 0.0006866347474297591

```

the types of numbers are:

```julia
julia> typeof(x)
Array{Union{Missing, Int64},1}
julia> typeof(y)
Int64
julia> typeof(z)
LinearAlgebra.Adjoint{Float64,Array{Float64,1}}

```

I don’t feel confident with this `LinearAlgebra` number so I would like to convert the numbers to normal types. Hence I tried to convert x to an integer but:

```julia
julia> parse(UInt32, x)
ERROR: MethodError: no method matching parse(::Type{UInt32}, ::Array{Union{Missing, Int64},1})
Closest candidates are:
  parse(::Type{T<:Integer}, ::AbstractChar; base) where T<:Integer at parse.jl:38
  parse(::Type{T<:Integer}, ::AbstractString; base) where T<:Integer at parse.jl:228
  parse(::Type{T<:Real}, ::AbstractString) where T<:Real at parse.jl:366
Stacktrace:
 [1] top-level scope at none:0

julia> convert(UInt32, x)
ERROR: MethodError: Cannot `convert` an object of type Array{Union{Missing, Int64},1} to an object of type UInt32
Closest candidates are:
  convert(::Type{T<:Number}, ::T<:Number) where T<:Number at number.jl:6
  convert(::Type{T<:Number}, ::Number) where T<:Number at number.jl:7
  convert(::Type{T<:Integer}, ::Ptr) where T<:Integer at pointer.jl:23
  ...
Stacktrace:
 [1] top-level scope at none:0

```

What is the correct procedure to convert an array to an integer of float in Julia?  
Thank you

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [May 3, 2019, 9:10am UTC](https://discourse.julialang.org/t/julia-convert-1-element-array-to-integer/23805/2 "2019-05-03T09:10:47Z")

</div>

```julia
julia> x = Union{Int,Missing}[42]
1-element Array{Union{Missing, Int64},1}:
 42

julia> typeof(ans)
Array{Union{Missing, Int64},1}

julia> x[1]
42

julia> typeof(ans)
Int64

```

---

<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:** [May 3, 2019, 9:20am UTC](https://discourse.julialang.org/t/julia-convert-1-element-array-to-integer/23805/3 "2019-05-03T09:20:11Z")

</div>

You can just use `first` to extract a single element.
