I have this dataframe:
In[1]df = pd.DataFrame([[1,2,3,4,5],[6,7,8,9,10],[11,12,13,14,15],[16,17,18,19,20],[21,22,23,24,25]])
In[2]df
Out[2]: 
    0   1   2   3   4
0   1   2   3   4   5
1   6   7   8   9  10
2  11  12  13  14  15
3  16  17  18  19  20
4  21  22  23  24  25
I need to achieve this:
- for every rows in my dataframe,
- if 2 or more values within any 3 consecutive cells is greater than 10,
- then the last of that 3 cells should be marked as True.
The resulting dataframe df1 should be same size with True of False in it based on the above stated criteria:
In[3]df1
Out[3]: 
    0   1      2      3      4
0 NaN NaN  False  False  False
1 NaN NaN  False  False  False
2 NaN NaN   True   True   True
3 NaN NaN   True   True   True
4 NaN NaN   True   True   True
- df1.iloc[0,1] is NaN bacause in that cell, only two numbers were given but needed atleast 3 numbers to do the test.
- df1.iloc[1,3] is False since none in [7,8,9] is greater than 10
- df1.iloc[3,4] is True since 2 or more in [18,19,20] is greater than 10
I figured dataframe.rolling.apply() with a function might be the solution, but how exactly?
 
     
     
     
    