0

I am trying to get the rolling(N) value to get the max from other column. e.g.

data

    Value   RollV   Maxrol  Requiredoutput

0   541.95      1   0   0

1   541.9       2   0   541.95

2   541.5   3   0   541.95

3   542.05  4   0   542.05

4   541.07  3   0   542.05

I trying the code.

data['Maxrol'] = data['Value'].rolling(window=int(data.iloc[-1,1])).max().shift(1).fillna(0)

and I am getting all zero value output. Please help to get the desired value

aaossa
  • 3,468
  • 2
  • 19
  • 33
  • Something along the lines of this was answered here: [Rolling sum on a dynamic window](https://stackoverflow.com/questions/59919277/rolling-sum-on-a-dynamic-window) , in your case, we need the max – anky Mar 06 '22 at 03:09

0 Answers0