Viewing columns and datatype in dataframe

I created a dataframe first:

using DataFrames
df = DataFrame(id=[1,2,3], 
    age=[30, 30, 32])

To view column names and datatypes, used:

Dict(names(df) .=> eltype.(eachcol(df)))

However, it gets the job done but is there any better way for this, like any function or using package?

More verbose:

julia> describe(df)
3Γ—7 DataFrame
 Row β”‚ variable  mean       min    median   max    nmissing  eltype
     β”‚ Symbol    Float64    Int64  Float64  Int64  Int64     DataType
   1 β”‚ id           2.0         1      2.0      3         0  Int64
   2 β”‚ salary    4500.0      4500   4500.0   4500         0  Int64
   3 β”‚ age         30.6667     30     30.0     32         0  Int64

if you really don’t want to know anything else:

julia> describe(df, :eltype)
3Γ—2 DataFrame
 Row β”‚ variable  eltype
     β”‚ Symbol    DataType
   1 β”‚ id        Int64
   2 β”‚ salary    Int64
   3 β”‚ age       Int64
describe(df, :eltype)

It’s neat indeed! Thanks for helping out!

1 Like


julia> mapcols(eltype, df)
1Γ—3 DataFrame
 Row β”‚ id        salary    age
     β”‚ DataType  DataType  DataType
   1 β”‚ Int64     Int64     Int64