I have a dataframe where I have set one column larger than another column.
df['y'] = (df['a'] > df['b']).astype(int)
from this i got a new column with 1 and 0. Now I would like to get out with the rolling window function all columns, where the 1 9 is repeated consecutively and then the applicable values from the column df['a'] copied into a new column and fill the not applicable rows with nan
a b y z
-0.143 -0.109 0 nan
-0.109 -0.108 1 nan
-0.118 -0.108 1 nan
-0.118 -0.113 1 nan
-0.090 -0.110 0 nan
-0.090 -0.108 0 nan
-0.075 -0.050 1 -0.075
-0.075 -0.059 1 -0.075
-0.065 -0.056 1 -0.065
-0.065 -0.053 1 -0.065
-0.042 -0.040 1 -0.042
-0.042 -0.039 1 -0.042
-0.064 -0.060 1 -0.064
-0.064 -0.057 1 -0.064
-0.055 -0.054 1 -0.055
-0.055 -0.053 1 -0.055
-0.068 -0.069 0 nan
-0.068 -0.056 1 nan
-0.074 -0.075 0 nan
-0.063 -0.076 0 nan
-0.074 -0.056 1 nan
-0.063 -0.069 0 nan
-0.077 -0.075 1 nan
-0.077 -0.050 1 nan
-0.082 -0.058 1 nan
-0.127 -0.056 1 nan
-0.095 -0.100 0 nan
-0.095 -0.094 1 nan
-0.108 -0.096 1 nan