Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import pandas as pd
- df = pd.DataFrame({'C1':[7,3,2,8,3,4,6,8,3,2],'C2':[2,5,4,8,8,8,3,2,8,4],'C3': [7,5,4,6,7,8,6,8,1,7],
- 'C4':[3,4,4,6,4,2,6,3,2,6],'C5':[6,4,0,8,4,2,6,6,7,8],'Year':[2010,2011,2012,2013,2014,2015,2016,2017,2018,2019]})
- df.set_index('Year', inplace=True)
- df1 =df[::-1]
- df1
- _1_CorrA =((df1.eq(8)) & (df1.shift(-1).isin([1,6])) & (df1.shift(-2).isin([1,6]))).sum(axis=1)==1
- _1_CorrB =(((df1.eq(8)) & (df1.shift(-1).eq(8)) & (df1.shift(-2).eq(8))) |
- ((df1.eq(8)) & (df1.shift(-1).isin([1,6])) & (df1.shift(-2).isin([1,6])))).sum(axis=1)==1
- Strategy = (((_1_CorrA) & (_1_CorrB)))
- df1['Success']=np.where(Strategy,1,0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement