I want to select a row from a dataframe and update a value on that row using a message received via zmq. So the message would provide
Bucket = “bucket_1” # this would add a new row to the empty dataframe
field_in = “Latency”
value_in = 34.90
so the intent is to add the bucket_1 row to the empty dataframe and use the “field_in” variable to locate df_test.latency and update the new row.
from docs
I can see that I can
julia> df[!, r"x"]
1×2 DataFrame
Row │ x1 x2
│ Int64 Int64
─────┼──────────────
1 │ 1 2
so I set up an empty dataframe and gave it some column names.
julia> test_col_names = ["Bucket","Tolling","Latency"]
julia> df_test = DataFrame(test_col_names .=> rand.([String,Float64,Float64],0))
julia> describe(df_test)
3×7 DataFrame
Row │ variable mean min median max nmissing eltype
│ Symbol Union… Nothing Nothing Nothing Int64 DataType
─────┼─────────────────────────────────────────────────────────────────
1 │ Bucket 0 String
2 │ Tolling NaN 0 Float64
3 │ Latency NaN 0 Float64
typed in a test value for field_in and tried out what I “thought” the docs said would work.
julia> field_in = "Tolling"
"Tolling"
julia> df_test[!,rfield_in]
and got
ERROR: UndefVarError: rfield_in not defined
Stacktrace:
[1] top-level scope
@ REPL[23]:1
can someone point out what I am missing please.
I want to end up with df_test looking like this
bucket | tolling | latency
bucket_1 | 0 | 34.90
and later on if I get a message
Bucket = “bucket_1” # this would add a new row to the empty dataframe
field_in = “Tolling”
value_in = 1.9902
bucket | tolling | latency
bucket_1 | 1.9902 | 34.90
but first I have to get the column selection working. Any help appreciated.