Error in selecting column dataframe with Julia 1.2

Hello,
I have been using this formula to get a value of a given dataframe’s column:

julia> println(df[(df[:Parameter] .== "dilution"), :5][1]
       )
┌ Warning: `getindex(df::DataFrame, col_ind::ColumnIndex)` is deprecated, use `df[!, col_ind]` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
1/h

It was working good (and still it works) but now that I have Julia 1.2 I get these warnings.
What is the syntax for this command now?
I tried with these:

julia> df[!, :Parameter] .== "burst"
19-element BitArray{1}:
 1
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0

julia> df[!, :Parameter] .== "burst", :5
(Bool[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 5)

julia> df[!, :Parameter] .== "burst", :5[1]
(Bool[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 5)

but I am obviously doing it wrong. Thanks

Try

println(df[(df[!, :Parameter] .== "dilution"), :5][1])

or

println(df[(df.Parameter .== "dilution"), :5][1])

note that the paranthesis are not needed in case you have just one logical condition. So this works too

println(df[df.Parameter .== "dilution", :5][1])
1 Like

Exactly - the getproperty approach is typically preferred. The ! syntax is OK, to be used, but it was originally intended for cases when you are not able to get a clean access using getproperty.

1 Like

Hi, I have another issue: with the df.Parameter syntax, the variables are extracted as characters. Is that normal? how can I avoid it?