title: count number of elements in column pandas based on another column's value
body: <p>I am trying to count the number of times a value has occurred on the based of another column value in pandas dataframe.Here is the data frame:</p>
  <p><a href="https://i.stack.imgur.com/ZTxVC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZTxVC.png" alt="enter image description here" /></a></p>
  <p>Basically, I want to count the number of times 1 occur in team 1 or team 2 in the season 2017(based on year).Till now here is my code</p>
  <pre><code>total_wins={}
  teams=matches['team1'].unique()
  for i in teams:
      total_matches[i]=len(matches[matches['winner'] == i])+len(matches[matches['team2'] == i])
  </code></pre>