title: Python pandas - filter rows after groupby
body: <p>For example, I have the following table:</p>
  <pre><code>index,A,B
  0,0,0
  1,0,8
  2,0,8
  3,1,5
  4,1,3
  </code></pre>
  <p>After grouping by <code>A</code>:</p>
  <pre><code>0:
  index,A,B
  0,0,0
  1,0,8
  2,0,8
  
  1:
  index,A,B
  3,1,5
  4,1,3
  </code></pre>
  <p>What I need is to drop rows from each group, where the number in column <code>B</code> is less than maximum value from all rows from group's column <code>B</code>. Well I have a problem translating and formulating this problem to English so here is the example:</p>
  <p>Maximum value from rows in column <code>B</code> in group <code>0</code>: <strong>8</strong></p>
  <p>So I want to drop row with index <code>0</code> and keep rows with indexes <code>1</code> and <code>2</code></p>
  <p>Maximum value from rows in column <code>B</code> in group <code>1</code>: <strong>5</strong></p>
  <p>So I want to drop row with index <code>4</code> and keep row with index <code>3</code></p>
  <p>I have tried to use pandas filter function, but the problem is that it is operating on all rows in group at one time:</p>
  <pre><code>data = &lt;example table&gt;
  grouped = data.groupby(&quot;A&quot;)
  filtered = grouped.filter(lambda x: x[&quot;B&quot;] == x[&quot;B&quot;].max())
  </code></pre>
  <p><strong>So what I ideally need is some filter, which iterates through all rows in group.</strong></p>
  <p>Thanks for help!</p>
  <p>P.S. Is there also way to only delete rows in groups and do not return <code>DataFrame</code> object?</p>