# How to filter dataframe rows with a boolean mask?

**URL:** <https://discourse.julialang.org/t/how-to-filter-dataframe-rows-with-a-boolean-mask/121873>\
**Category:** General Usage\
**Tags:** dataframes, boolean\
**Created:** [October 28, 2024, 2:47pm UTC](https://discourse.julialang.org/t/how-to-filter-dataframe-rows-with-a-boolean-mask/121873 "2024-10-28T14:47:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ju\_ska](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Post date:** [October 28, 2024, 2:47pm UTC](https://discourse.julialang.org/t/how-to-filter-dataframe-rows-with-a-boolean-mask/121873/1 "2024-10-28T14:47:32Z")

</div>

Hi,

I would like to the same thing as this python code:

```julia
import pandas as pd

array = [1,2,3]
df = pd.DataFrame(array)
mask = [True, False, True]
new_df = df[mask]

```

```julia
>>> print(new_df)
   0
0 1
2 3

```

Looked around, but didn’t find a short answer.

---

<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:** [October 28, 2024, 2:58pm UTC](https://discourse.julialang.org/t/how-to-filter-dataframe-rows-with-a-boolean-mask/121873/2 "2024-10-28T14:58:46Z")

</div>

```julia
new_df = df[mask, :]

```

---

<div class="post-metadata">

**Author:** ![Ju\_ska](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Post date:** [October 28, 2024, 3:28pm UTC](https://discourse.julialang.org/t/how-to-filter-dataframe-rows-with-a-boolean-mask/121873/3 "2024-10-28T15:28:45Z")

</div>

Thanks !
