# Finding a conditioned row in a dataframe

**URL:** https://discourse.julialang.org/t/finding-a-conditioned-row-in-a-dataframe/29347
**Category:** General Usage
**Created:** [October 1, 2019, 2:54am UTC](https://discourse.julialang.org/t/finding-a-conditioned-row-in-a-dataframe/29347 "2019-10-01T02:54:59Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Dervis](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@Dervis](https://discourse.julialang.org/u/Dervis)
#### Post date: [October 1, 2019, 2:54am UTC](https://discourse.julialang.org/t/finding-a-conditioned-row-in-a-dataframe/29347/1 "2019-10-01T02:54:59Z")

</div>

Dear all,

I am trying to find the index (row number) of specific row that I am conditioning from a large dataset (33000 rows x 9 columns). The columns of the dataset are date(year, month, day) & time(hour, min, sec) & GPS (lat, long, alt). Is there an easy and quick way to search and find a specific (conditioned) row i.e. I would like to condition year, month, day, hour, min and sec? I tried findall() but it didnt work out since it is not able to condition multiple columns. Any help will be appreciated.

I tried:

findall((x,y)-\> x==2019 in raw\_ch\_harvest[:,1] , y==5 in raw\_ch\_harvest[:,2])

also tried

[(raw\_ch\_harvest[:,1] .== 2019) & (raw\_ch\_harvest[:,2] .== 5) & (raw\_ch\_harvest[:,3] .== 17)]

Thanks

---

<div class="post-metadata">

### Author: ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)
#### Post date: [October 1, 2019, 3:32am UTC](https://discourse.julialang.org/t/finding-a-conditioned-row-in-a-dataframe/29347/2 "2019-10-01T03:32:24Z")

</div>

Assuming that you want to condition on a specific date, here’s an example.

```julia
# simulate some datetime data
date = DateTime("1990-01-01"):Hour(1):DateTime("2000-01-01")
D=DataFrame(y=year.(date), m=month.(date), d=day.(date), h=hour.(date), v=rand(87649))
D.date = DateTime.(eachcol(D[!,1:4])...)
D.date.==DateTime(1990, 1, 1, 12)

```

---

<div class="post-metadata">

### Author: ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)
#### Post date: [October 1, 2019, 5:43pm UTC](https://discourse.julialang.org/t/finding-a-conditioned-row-in-a-dataframe/29347/3 "2019-10-01T17:43:09Z")

</div>

```julia
df = DataFrame(:year => rand(collect(1990 : 2000), 10), :month => rand(collect(1:12), 10));
findall((df.year .== 1992) .& (df.month .== 4))
1-element Array{Int64,1}:
 2

```

---

<div class="post-metadata">

### Author: ![Dervis](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@Dervis](https://discourse.julialang.org/u/Dervis)
#### Post date: [October 2, 2019, 1:55pm UTC](https://discourse.julialang.org/t/finding-a-conditioned-row-in-a-dataframe/29347/4 "2019-10-02T13:55:58Z")

</div>

Thank you very much, that is the simple one and really worked!

---

<div class="post-metadata">

### Author: ![Dervis](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@Dervis](https://discourse.julialang.org/u/Dervis)
#### Post date: [October 2, 2019, 1:56pm UTC](https://discourse.julialang.org/t/finding-a-conditioned-row-in-a-dataframe/29347/5 "2019-10-02T13:56:11Z")

</div>

Thanks for the advice
