Finding a conditioned row in a dataframe

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

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

# 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)

2 Likes
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
3 Likes

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

Thanks for the advice