I am using the DataFrames package, and I would like to set a string column of it as the index. For example, let x =
│ Row │ name │ val│
│ │ String │ String │
├─────┼────────┼────────┤
│ 1 │ A │ 1│
│ 2 │ B │ 2│
│ 3 │ C │ 4│
│ 4 │ D │ 3│
│ 5 │ E │ 4│
│ 6 │ X │ 5│
Then, I want something like x[“A”, :val] to return 1. Currently, I have to do the following
@where(x, :name .== "A")[1, :val]
which is bulky and unclear that the @where should only return one row. Is there anything like pandas set_index
or an alternative? I’m having trouble understanding setIndex!
in the DataFrames documentation, but it states that indices must be integers in any case.