This is my first time using stack overflow, and I still don't know how to properly add code lines so excuse me.
The title might not explain enough the problem I'm stuck with. I have a first dataframe (let's call it df1
) that contains a column of datetimes for each hour since 1990 and another column for wave height. I created another dataframe (df2
) with the start & end date & duration of the slot where the wave height doesn't surpass a certain value.
What I would like to achieve now, is simply adding the mean()
of the wave height in each available slot to my df2. However, since the wave height to all the dates (including those where waveheight > my value condition) are in df1, I don't seem to find the appropriate method to iterate into my df1 and select into df2 only the wave height values where (start date <= df1.time <= end date) for each slot. I'm able to do it for only one slot for the moment.
I'm still new to the Pandas logic, I know that we should avoid using loops but I can't see how to achieve my goal without looping.