Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def myfunc(rolling_window) :
- count=0
- n=len(rolling_window)
- if rolling_window[-1]!=0 :
- return 0
- else :
- for i in range(0,n) :
- if rolling_window[n-i-1] ==0 :
- count=count + 1
- else :
- break
- return count
- df2['zerocum']=df2.groupby(['customerParentID','forecastGroup'])['demandQuantity'].shift(6).rolling(window=36,min_periods=1).apply(myfunc)
- df2['zerocum']=df2.['demandQuantity'].shift(6).rolling(window=36,min_periods=1).apply(myfunc)
Add Comment
Please, Sign In to add comment