queryverse / Query.jl

Query almost anything in julia
Other
394 stars 49 forks source link

Correct way to reference a column name in a dataframe with Query `_.b` vs `:b`? #331

Open rleyvasal opened 3 years ago

rleyvasal commented 3 years ago

Looking at the Query getting started page I came across two different ways to reference column names in a data frame.

I want to know what is the correct way to reference a column in a dataframe and why there is an inconsistency in referencing column names.

_.b

using Query, DataFrames, Statistics
df = DataFrame(a=[1,1,2,3], b=[4,5,6,8])
df2 = df |>
    @groupby(_.a) |>
    @map({a=key(_), b=mean(_.b)}) |>
    @filter(_.b > 5) |>
    @orderby_descending(_.b) |>
    DataFrame

:b

df = DataFrame(a=[1,2,3], b=[4,missing,5])

q = df |> @dropna(:b) |> DataFrame