# Selecting rows from a data frame using multiple conditions

**URL:** <https://discourse.julialang.org/t/selecting-rows-from-a-data-frame-using-multiple-conditions/73282>\
**Category:** Data\
**Tags:** question, dataframes\
**Created:** [December 17, 2021, 8:59pm UTC](https://discourse.julialang.org/t/selecting-rows-from-a-data-frame-using-multiple-conditions/73282 "2021-12-17T20:59:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [December 17, 2021, 9:07pm UTC](https://discourse.julialang.org/t/selecting-rows-from-a-data-frame-using-multiple-conditions/73282/2 "2021-12-17T21:07:22Z")

</div>

You need to broadcast the `&`.

```julia
d_f[(d_f.A .== 3) .& (d_f.B .== "c"), :]

```

If you are using version 1.7, you can actually use the safer `&&`, which is actually control flow, rather than `&`, which is “bitwise OR”.

```julia
julia> d_f[(d_f.A .== 3) .&& (d_f.B .== "c"), :]
1×2 DataFrame
 Row │ A B      
     │ Int64 String 
─────┼───────────────
   1 │ 3 c

```

Finally, if you are using DataFramesMeta.jl, you can do

```julia
julia> using DataFramesMeta

julia> @rsubset(d_f, :A == 3, :B == "c")
1×2 DataFrame
 Row │ A B      
     │ Int64 String 
─────┼───────────────
   1 │ 3 c

```

---

_[View the full topic](https://discourse.julialang.org/t/selecting-rows-from-a-data-frame-using-multiple-conditions/73282)._
