Hi,
how to properly check if a column is present in a dataframe ?
E.g. verify col1, col3.
using DataFrames
df = DataFrame(col1 = [1, 2], col2 = [2, 1])
Hi,
how to properly check if a column is present in a dataframe ?
E.g. verify col1, col3.
using DataFrames
df = DataFrame(col1 = [1, 2], col2 = [2, 1])
"col1" in names(df)
or use the columnindex
function.
Neat !
Thanks everyone.
julia> df = DataFrame(randn(10, 10_000), :auto);
julia> @time hasproperty(df, :x1)
0.000035 seconds
true
julia> @time "x1" in names(df)
0.000434 seconds (10.00 k allocations: 330.438 KiB)
true
Surprised to learn that hasproperty(df, "x1")
also works using a string.