1

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)

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.