I am trying to subset a dataframe by filtering out rows which contain “/”.
I have:
@subset(gdf, contains.(:country, "/"))
Which works for highlighting all the of the rows with “/” but adding ! or /isnot didn’t seem to work. I tried another way with:
filter(:country => !=("/"), gdf)
but this didn’t work either.
Is there a way to exclude using contains? or is there a different way?
julia> using DataFrames
julia> @subset
ERROR: LoadError: UndefVarError: @subset not defined
in expression starting at REPL[6]:1
so where is @subset from, i.e. what are you using
?
This will work though:
filter(row->!occursin("/", row.country), gdf)
You are having trouble with the broadcasted !
I think.
- You could use
@rsubset
for row-wise operations
julia> @rsubset df !contains(:country, "/")
1×1 DataFrame
Row │ country
│ String
─────┼─────────
1 │ a
- You could use broadcasted
!
julia> @subset df .!contains.(:country, "/")
1×1 DataFrame
Row │ country
│ String
─────┼─────────
1 │ a
2 Likes