using DataFrames, Query
df = DataFrame()
df[:Name] = ["Alice", "Arthur", "Bob", "Charlie"]
df[:Diet] = [["apple", "orange", "onion"],
[],
["banana", "onion", "cake"],
["olives", "peanut butter", "avocado"]]
df[:Weight] = [70, 90, 80, 60]
使用查询。jl:
julia> q1 = @from i in df begin
@where startswith(get(i.Name), "A")
@select {i.Name, i.Diet, i.Weight}
@collect DataFrame
end
2Ã3 DataFrames.DataFrame
â Row â Name â Diet â Weight â
âââââââ¼âââââââââââ¼âââââââââââââââââââââââââ¼âââââââââ¤
â 1 â "Alice" â Any["apple", "orange"] â 70 â
â 2 â "Arthur" â Any[] â 90 â
但是如何询问涉及关键字的查询。例如,谁吃洋葱?
julia> q2 = @from i in df begin
# @where ??? a keyword in i.Diet starting with "on"?
@select {i.Name, i.Diet, i.Weight}
@collect DataFrame
end
我知道
Query.jl
能够使用数据库。