title: Using conditional if/else logic with pandas dataframe columns
body: <p>My dataframe called <code>pw2</code> looks something like this, where I have two columns, pw1 and pw2, which are probability of wins. I'd like to perform some conditional logic to create another column called <code>WINNER</code> based off <code>pw1</code> and <code>pw2</code>.</p>
  
  <pre><code>+-------------------------+-------------+-----------+-------------+
  |          Name1          |     pw1     |   Name2   |     pw2     |
  +-------------------------+-------------+-----------+-------------+
  | Seaking                 | 0.517184213 | Lickitung | 0.189236181 |
  | Ferrothorn              | 0.172510623 | Quagsire  | 0.260884258 |
  | Thundurus Therian Forme | 0.772536272 | Hitmonlee | 0.694069408 |
  | Flaaffy                 | 0.28681284  | NaN       | NaN         |
  +-------------------------+-------------+-----------+-------------+
  </code></pre>
  
  <p>I want to do this conditionally in a function but I'm having some trouble.</p>
  
  <ul>
  <li>if <code>pw1</code> > <code>pw2</code>, populate with <code>Name1</code></li>
  <li>if <code>pw2</code> > <code>pw1</code>, populate with <code>Name2</code></li>
  <li>if <code>pw1</code> is populated but <code>pw2</code> isn't, populate with <code>Name1</code></li>
  <li>if <code>pw2</code> is populated but <code>pw1</code> isn't, populate with <code>Name2</code></li>
  </ul>
  
  <p>But my function isn't working - for some reason checking if a value is null isn't working.</p>
  
  <pre><code>def final_winner(df):
      # If PW1 is missing and PW2 is populated, Pokemon 1 wins
      if df['pw1'] = None and df['pw2'] != None:
          return df['Number1']
      # If it's the same thing but the other way around, Pokemon 2 wins
      elif df['pw2'] = None and df['pw1'] != None:
          return df['Number2']
      # If pw2 is greater than pw1, then Pokemon 2 wins
      elif df['pw2'] &gt; df['pw1']:
          return df['Number2']
      else
          return df['Number1']
  
  pw2['Winner'] = pw2.apply(final_winner, axis=1)
  </code></pre>