title: How can I make this code into more idiomatic pandas?
body: <p>Kind of a broad question, but I am not sure how else to get pointers on how to improve this code.</p>
  <p>I have a dataframe which has betting odds and game results, and I would like to compute the payout of investing in a certain team.</p>
  <p>The code I have now works, but I feel like it skimps on much of what Pandas can do by just leaning on the <code>apply</code> method and dropping into Python.</p>
  <p>Here's what the dataframe looks like:
  <a href="https://i.stack.imgur.com/8dMcu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8dMcu.png" alt="enter image description here" /></a></p>
  <p>And here is my code:</p>
  <pre><code>def compute_payout(odds, amount=1):
      if odds &lt; 0:
          return amount/(-1.0 * odds/100.0)
      elif odds &gt; 0:
          return amount/(100.0/odds)
  
  def game_payout(row, team_name):
      if row['home_team'] == team_name:
          if row['home_score'] &gt; row['away_score']:
              return compute_payout(row['home_odds'])
          else:
              return -1
      elif row['away_team'] == team_name:
          if row['away_score'] &gt; row['home_score']:
              return compute_payout(row['away_odds'])
          else:
              return -1
  
  payout = df.apply(lambda row: game_payout(row, team_name), axis=1)
  </code></pre>
  <p>Any suggestions are deeply appreciated!</p>