title: How to get number of rows in a grouped-by category in pandas
body: <p>In <code>pandas</code>, I have (<code>app_categ_events</code> is a <code>dataframe</code>):</p>
  
  <pre><code>&gt; print(app_categ_events.label_id.unique().shape)
  &gt; print(app_categ_events.category.unique().shape)
  
  Out:
  (492,)
  (458,)
  </code></pre>
  
  <p>I want to look at the <code>label_category</code>’s that have more than one <code>label_id</code> for each (because I thought there was supposed to be a one-to-one mapping).</p>
  
  <p>In <a href="/questions/tagged/r" class="post-tag" title="show questions tagged &#39;r&#39;" rel="tag">r</a> <code>data.table</code>, I can do:</p>
  
  <pre><code>app_categ_events[, count_rows := .N, by = list(category, label_id)]
  # (or smth of that sort...)
  print(app_categ_events[counts_rows &gt; 1])
  </code></pre>
  
  <p>What’s the best way of doing that in <code>pandas</code>?</p>