title: How to COUNT OVER PARTITION BY in Pandas
body: <p>What is the pandas equivalent of the window function below</p>
  
  <pre><code>COUNT(order_id) OVER(PARTITION BY city)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/7lU0e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7lU0e.png" alt="enter image description here"></a></p>
  
  <p>I can get the row_number or rank</p>
  
  <pre><code>df['row_num'] = df.groupby('city').cumcount() + 1
  </code></pre>
  
  <p>But COUNT PARTITION BY city like in the example is what I'm looking for</p>