I created a dataframe first:
using DataFrames
df = DataFrame(id=[1,2,3],
salary=4500,
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?
nilshg
2
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
6 Likes
describe(df, :eltype)
Itβs neat indeed! Thanks for helping out!
1 Like
or
julia> mapcols(eltype, df)
1Γ3 DataFrame
Row β id salary age
β DataType DataType DataType
ββββββΌββββββββββββββββββββββββββββββ
1 β Int64 Int64 Int64
3 Likes