Hi I have the following function to decide the winner:
def winner(T1,T2,S1,S2,PS1,PS2):
    if S1>S2:
        return T1        
    elif S2>S1:
        return T2
    else:
        #print('Winner will be decided via penalty shoot out')
        Ninit = 5
        Ts1 = np.sum(np.random.random(size=Ninit))*PS1
        Ts2 = np.sum(np.random.random(size=Ninit))*PS2
        if Ts1>Ts1:
            return T1
        elif Ts2>Ts1:
            return T2
        else:
            return 'Draw'
And I have the following data frame:
df = pd.DataFrame()
df['Team1']   = ['A','B','C','D','E','F']
df['Score1']  = [1,2,3,1,2,4]
df['Team2']   = ['U','V','W','X','Y','Z']
df['Score2']  = [2,2,2,2,3,3]
df['Match']   = df['Team1']  + ' Vs '+ df['Team2']
df['Match_no']= [1,2,3,4,5,6]
df ['P1'] = [0.8,0.7,0.6,0.9,0.75,0.77]
df ['P2'] = [0.75,0.75,0.65,0.78,0.79,0.85]
I want to create a new column in which winner from each match will be assigned. To decide a winner from each match, I used the function winner. I tested the function using arbitrary inputs. it works. When I used dataframe,
as follow:
df['Winner']= winner(df.Team1,df.Team2,df.Score1,df.Score2,df.P1,df.P2)
it showed me the following error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Can anyone advise why there is an error? Thanks
Zep.
 
    