# Condition for numeric table column type

**URL:** <https://discourse.julialang.org/t/condition-for-numeric-table-column-type/58011>\
**Category:** New to Julia\
**Tags:** numbers, type\
**Created:** [March 26, 2021, 12:27pm UTC](https://discourse.julialang.org/t/condition-for-numeric-table-column-type/58011 "2021-03-26T12:27:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laco\_Kovac](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laco_kovac/32/20684_2.png) [@Laco\_Kovac](https://discourse.julialang.org/u/Laco_Kovac)\
**Post date:** [March 26, 2021, 12:27pm UTC](https://discourse.julialang.org/t/condition-for-numeric-table-column-type/58011/1 "2021-03-26T12:27:58Z")

</div>

I am importing data from database, getting DataFrame.  
I am supposed to import only numeric columns, either Integer or floating point.  
If the column is nullable, type is a Union of Missing & type, e.g. Union{Missing, Float64}.

Here is the code I am using currently:

```julia
function columnTypeCompare(coltype, aType)::Bool
    return (coltype === aType) || (coltype === Union{Missing, aType})
end

function isAcceptableDataType(coltype)::Bool
    for oneDataType in [Int8,Int16,Int32,Int64,Int128,UInt8,UInt16,UInt32,UInt64,UInt128,Float16,Float32,Float64]
        if columnTypeCompare(coltype, oneDataType)
            return true
        end
    end
    return false
end

```

But I suspect there has to be easier way to determine this, using maybe Core.Number or something like that. Any suggestion(s)?

Thank you.

---

<div class="post-metadata">

**Author:** ![chris-b1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chris-b1/32/14165_2.png) [@chris-b1](https://discourse.julialang.org/u/chris-b1)\
**Post date:** [March 26, 2021, 12:56pm UTC](https://discourse.julialang.org/t/condition-for-numeric-table-column-type/58011/2 "2021-03-26T12:56:52Z")

</div>

You want the subtype operator (`<:`) - see docs [here](https://docs.julialang.org/en/v1/base/base/#Core.:%3C:) and [here](https://docs.julialang.org/en/v1/manual/types/)

```julia
is_acceptable(coltype) = coltype <: Union{Number, Missing}

julia> is_acceptable(Float64)
true

julia> is_acceptable(Union{Int8, Missing})
true

julia> is_acceptable(String)
false

```

---

<div class="post-metadata">

**Author:** ![Laco\_Kovac](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laco_kovac/32/20684_2.png) [@Laco\_Kovac](https://discourse.julialang.org/u/Laco_Kovac)\
**Post date:** [March 26, 2021, 1:01pm UTC](https://discourse.julialang.org/t/condition-for-numeric-table-column-type/58011/3 "2021-03-26T13:01:48Z")

</div>

Thank you!
