How to deal with these Float32[1.4765211f6]?

my code here:

julia> data_y
255-element Array{Any,1}:
 Float32[4805.912]
 Float32[10600.066]
 Float32[16394.223]
 Float32[22188.377]
 Float32[27982.531]
 Float32[33776.684]
 Float32[39570.844]
 Float32[45364.992]
 Float32[51159.145]
 Float32[56953.3]
 Float32[62747.46]
 Float32[68541.61]
 Float32[74335.766]
 ⋮
 Float32[1.4127855f6]
 Float32[1.4185798f6]
 Float32[1.4243738f6]
 Float32[1.4301679f6]
 Float32[1.4359622f6]
 Float32[1.4417564f6]
 Float32[1.4475504f6]
 Float32[1.4533446f6]
 Float32[1.4591389f6]
 Float32[1.464933f6]
 Float32[1.4707271f6]
 Float32[1.4765211f6]

but i want it to like this:

255-element Array{Float64,1}:
   555.0
   654.0
   941.0
  1434.0
  2118.0
  2927.0
  5578.0
  6167.0
  8235.0
  9927.0
 12038.0
 16787.0
 19887.0
     ⋮
     3.1326812e7
     3.1605997e7
     3.1873009e7
     3.2233965e7
     3.2564294e7
     3.2841726e7
     3.3078941e7
     3.3355107e7
     3.364296e7
     3.3968093e7
     3.4287239e7
     3.4582601e7

What should I do?

In the first case you have an array of arrays with one elements, you can grab that element with getindex, which you can broadcast on the initial array:

julia> y = Any[Float32[1], Float32[2]]
2-element Vector{Any}:
 Float32[1.0]
 Float32[2.0]

julia> getindex.(y)
2-element Vector{Float32}:
 1.0
 2.0
3 Likes

thank you! :grinning:

1 Like