Suppose I have a DataFrame in Julia and typeof((df[:,:col])) returns Array{Union{Missing, Float64},1}. How do I check the types within Union{Missing, Float64} to, for example, see if Float64 is in that Union, or to make sure that there are no String values in that Union?
You can use the subtype operator:
T1 = Union{Missing, Float64}
Float64 <: T1 # true
String <: T1 # false
This is because Float64 is a subtype of the union, whereas String is not (since it's not in the union).
If you're defining a method to dispatch on it, you could go a step further:
function doSomething(arr::Vector{Union{Missing, T}}) where T <: Float64
# do something
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With