Filtering a DataFrame column using Regex

I have a DataFrame that has this general structure

using DataFrames

df = DataFrame(Sites = ["N-1", "N-1", "A", "B", "N-2"], Other = [randn(5)])

How can I filter out the rows that are named “N-” on the column :Sites? I know I can use Regex and Not but my naive approach didn’t work.

filter(:Sites => x -> x == Not(r"N-"), df)

How can I perform this operation?

Not doesn’t work like that. The way you are working with Not is similar to a workflow one might use with selecting columns, not rows.

You want occursin

julia> filter(:Sites => t -> occursin(r"N", t) == false, df)
1 Like

Ok, good to know.

Thanks