title: Pandas dataframe filtering based on group counts
body: <p>My dataframe looks like this:</p>
  
  <pre><code>item_id       sales_quantity
     1              10             
     1              11 
     1              1 
     1              2
     ...            ...
     10             1
     10             9
     ...            ...
  </code></pre>
  
  <p>I want to filter out all the rows corresponding to an <code>item_id</code> which appear less than 100 times. Here is what I tried:</p>
  
  <pre><code>from pandas import *
  from statsmodels.tsa.stattools import adfuller
  def adf(X):
  
      result = adfuller(X)
      print('ADF Statistic: %f' % result[0])
      print('p-value: %f' % result[1])
      print('Critical Values:')
      for key, value in result[4].items():
          print('\t%s: %.3f' % (key, value))
  
  
  filtered = df.groupby('item_id_copy')['sales_quantity'].filter(lambda x: len(x) &gt;= 100)
  df[df['sales_quantity'].isin(filtered)]
  df['sales_quantity'].groupby(df['item_id_copy']).apply(adf)
  </code></pre>
  
  <p>But, when I run the following:
  <code>df['sales_quantity'].groupby(df['item_id_copy']).size()</code>, I get lots of item_ids with size less than 100. Can someone please tell me what is wrong with my code?</p>