How do I create a new DataFrame from another Dataframe by removing certain columns

I wish to create a new DataFrame from another Dataframe by removing certain columns.

I was hoping the following simple syntax would work, but I get the error “MethodError: no method matching InvertedIndex(::Symbol, ::Symbol)

select!(df, Not(:col1,:col4, col7))

What is the correct way to achieve my aim?

select(df, Not([:col1,:col4, :col7])) if you want to create a new data frame.

1 Like