Julia 1.3 selection of datafarme's column with :Col is deprecated

Hello,
I recently upgraded to Julia 1.3. Before I was using df[:Column] to select a dataframe’s column, but now I get the error:
Julia > Warning: getindex(df::DataFrame, col_ind::ColumnIndex)is deprecated, usedf[!, col_ind] instead.

What is the current syntax for selecting a dataframe’s column on Julia 1.3? Why is the syntax always changing? (the :Column way was easy to understand and similar to R’s $…)
Thank you

1 Like

Ok, but where can I find what syntax to use? Thanks

See DataFrames docs, this whole page is on indexing:
http://juliadata.github.io/DataFrames.jl/stable/lib/indexing/#Indexing-1

Thank you

And a short summary is, you can use the following syntax to get a column:

  • without copying it: df.col or df[!, :col] (the second form with ! in single column selection is not really needed as you can always use df.col which is what you wanted I guess as you referred to $ in R, it is needed if you want to select multiple columns or if you want to set a value of the column)
  • with copying it: df[:, :col]

Also in 1.3 if variable name is not a valid identifier then df.col should be written as df.var"1 2 3" if the variable name is Symbol("1 2 3") (which is not a valid identifier).

6 Likes