# Subset does not contain certain string

**URL:** https://discourse.julialang.org/t/subset-does-not-contain-certain-string/72109
**Category:** New to Julia
**Tags:** question
**Created:** [November 26, 2021, 1:19pm UTC](https://discourse.julialang.org/t/subset-does-not-contain-certain-string/72109 "2021-11-26T13:19:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Billpete002](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/billpete002/32/35091_2.png) [@Billpete002](https://discourse.julialang.org/u/Billpete002)
#### Post date: [November 26, 2021, 1:19pm UTC](https://discourse.julialang.org/t/subset-does-not-contain-certain-string/72109/1 "2021-11-26T13:19:30Z")

</div>

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:

```julia
filter(:country => !=("/"), gdf)

```

but this didn’t work either.

Is there a way to exclude using contains? or is there a different way?

---

<div class="post-metadata">

### Author: ![lawless-m](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lawless-m/32/30869_2.png) [@lawless-m](https://discourse.julialang.org/u/lawless-m)
#### Post date: [November 26, 2021, 1:31pm UTC](https://discourse.julialang.org/t/subset-does-not-contain-certain-string/72109/2 "2021-11-26T13:31:43Z")

</div>

```julia
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)`

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [November 26, 2021, 1:51pm UTC](https://discourse.julialang.org/t/subset-does-not-contain-certain-string/72109/3 "2021-11-26T13:51:02Z")

</div>

You are having trouble with the broadcasted `!` I think.

1. You could use `@rsubset` for row-wise operations

```julia
julia> @rsubset df !contains(:country, "/")
1×1 DataFrame
 Row │ country 
     │ String  
─────┼─────────
   1 │ a

```

1. You could use broadcasted `!`

```julia
julia> @subset df .!contains.(:country, "/")
1×1 DataFrame
 Row │ country 
     │ String  
─────┼─────────
   1 │ a

```
