# How would I filter columns that contain a particular substring?

**URL:** https://discourse.julialang.org/t/how-would-i-filter-columns-that-contain-a-particular-substring/42721
**Category:** General Usage
**Created:** [July 8, 2020, 11:15am UTC](https://discourse.julialang.org/t/how-would-i-filter-columns-that-contain-a-particular-substring/42721 "2020-07-08T11:15:01Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Julia1](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@Julia1](https://discourse.julialang.org/u/Julia1)
#### Post date: [July 8, 2020, 11:15am UTC](https://discourse.julialang.org/t/how-would-i-filter-columns-that-contain-a-particular-substring/42721/1 "2020-07-08T11:15:02Z")

</div>

Hi how’s it going?

Say I have this dataframe

```julia
initial = DataFrame(:day=>["monday","monday","monday"],:name=>["bob","mike","phillis"],:temp=>["medium","high","low, medium"],:gender=>["male, female","male","female"])

```

![Screenshot from 2020-07-08 07-14-07](https://global.discourse-cdn.com/julialang/original/3X/4/d/4d7c8f4d89155825f1b8e4a0fdfa8ad7d404d96b.png)

How would I extract the names of the columns that contain a comma in at least one of their values?

For the above DataFrame I need it to return :temp and :gender

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [July 8, 2020, 11:43am UTC](https://discourse.julialang.org/t/how-would-i-filter-columns-that-contain-a-particular-substring/42721/2 "2020-07-08T11:43:08Z")

</div>

One way:

```julia
names(initial)[[any(occursin.(",", c)) for c ∈ eachcol(initial)]]

```

---

<div class="post-metadata">

### Author: ![Julia1](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@Julia1](https://discourse.julialang.org/u/Julia1)
#### Post date: [July 8, 2020, 12:41pm UTC](https://discourse.julialang.org/t/how-would-i-filter-columns-that-contain-a-particular-substring/42721/3 "2020-07-08T12:41:04Z")

</div>

thank you!
