Convert type `Any` to `Symbol` to subset `DataFrame` columns


I am trying to subset a dataframe’s (DF) columns using a list of column names extracted using DataFrames.Terms(model_formula).terms which returns a type of Any object. I would like to convert this type Any to Symbol so I can subset a DF as indicated below;

This works fine;

using DataFrames
df = DataFrame()
df[:y] = randn(10)
df[:x1] = randn(10)
df[:x2] = randn(10)

name_list = [:x1, :x2]

However, this does not work as input_covariates is of type Any and produces following method mismatching error.
Any idea how to achieve my goal here??Thanks.
@mkborregaard @ChrisRackauckas

model_formula = y ~ x1 + x2
input_covariates = DataFrames.Terms(model_formula).terms




@mkborregaard: Thanks a lot.


@mkborregaard: Another quick question. How do I subset a Dictionary object by keys? Or

How do I subset object created by DataFrames.groupby()?