temperature precipitation
0 1.26 0.0279
1 1.64 0.0330
2 1.98 0.0381
3 2.31 0.0406
4 2.61 0.0406
5 2.89 0.0381
6 3.15 0.0356
7 3.51 0.0305
8 3.78 0.0305
9 3.78 0.0305
In the dataframe above, I want to create a new column C where the value is 1 for 4 rows after precipitation is less than 0.04 iff precipitation in those 4 rows is less than 0.04. I tried using pd.where but that only sets the value for the present row.
Expected output:
