I've dataframe like that:
| price | period |
|---|---|
| 124.22 | 5 |
| 126.51 | 6 |
| 121.3 | 6 |
| 125.25 | 4 |
df['lowest'] = df['price'].rolling(window=30).min().shift(1)
Now the rolling is applied base on 30 window. I need to apply for each row the corresponding period. Es: For first line price = 124.22 , window = 5
Something like that (this code not working...):
df['lowest'] = df['price'].rolling(window=df['period']).min().shift(1)