I have a pandas dataframe like this:
first second
0 True False
1 False True
2 True True
3 False False
4 False True
5 False True
6 True False
7 False False
that could be created with the code:
import pandas as pd
df = pd.DataFrame(
{
'first': [True, False, True, False, False, False, True, False],
'second': [False, True, True, False, True, True, False, False]
}
)
For any row having a True value in the first column, I want to find the first row in the next rows where the value of second column is True.
So the output should be:
first second
1 False True
4 False True
Also, it's my priority not to use any for-loops.
Have you any idea about this?