Hi. I have a dataframe like this:
I want to be able to get the numerical data for a single row, say, “Algeria”. This is the function that I wrote for that.
function get_country_data(country)
data_by_country |>
data -> filter(:country => val -> val == country, data) |>
data -> data[1, 2:end] |>
data -> convert(Vector, data)
end;
I try to call the function like this:
get_country_data("Algeria")
But this is the error I’m getting:
ArgumentError: column name :country not found in the data frame
lookupname@index.jl:288[inlined]
getindex@index.jl:297[inlined]
#filter#79@abstractdataframe.jl:1002[inlined]
filter@abstractdataframe.jl:1002[inlined]
(::Main.workspace79.var"#1#5"{String})(::DataFrames.DataFrame)@Other: 3
|>(::DataFrames.DataFrame, ::Main.workspace79.var"#1#5"{String})@operators.jl:834
get_country_data(::String)@Other: 2
top-level scope@Local: 1[inlined]
4 posts - 4 participants