How to dynamically call a column in a @where macro?

How can I dynamically refer to a column name (i.e., a Symbol) within a @where macro ?

using DataFrames, DataFramesMeta
df = DataFrame(x=Int64[1,2,3,4,5])
name = "x"
nameS = Symbol(name)
df2 = @where(df, :x .>= 2)       # ok
df2 = @where(df, nameS .>= 2)    # MethodError

I think you want the following, but I’m not where I can check it:

df2 = @where(df, _I_(nameS) .>= 2)
1 Like

Thank you, that’s work.
For reference, _I_ is documented in the @with section of DataFrameMeta.jl README.

1 Like