I am trying to apply the following function for each row in a dataframe. The dataframe looks as follows:
vote_1 vote_2 vote_3 vote_4
a      a       a      b           
b      b       a      b          
b      a       a      b           
I am tring to generate a fourth column to sum the 'votes' of the other columns and produce the winner, as follows:
vote_1 vote_2 vote_3 vote_4 winner_columns
a      a       a      b           a
b      b       a      b           b 
b      a       a      b           draw
I have currently tried:
def winner(x):
    a = new_df.iloc[x].value_counts()['a']
    b = new_df.iloc[x].value_counts()['b']
    if a > b:
        y = 'a'
    elif a < b:
        y = 'b'
    else:
        y = 'draw'
    return y
df['winner_columns'].apply(winner)
However the whole column gets filled with draws. I assume is something with the way I have build the function but can't figure out what
 
     
     
    