title: How to filter results of a groupby in pandas
body: <p>I am trying to filter out a result of a groupby.</p>
  
  <p>I have this table:</p>
  
  <pre><code>A       B       C
  
  A0      B0      0.5
  A1      B0      0.2
  A2      B1      0.6
  A3      B1      0.4
  A4      B2      1.0
  A5      B2      1.2
  </code></pre>
  
  <p><code>A</code> is the index and it is unique.</p>
  
  <p>Secondly I have this list:</p>
  
  <pre><code>['A0', 'A1', 'A4']
  </code></pre>
  
  <p>I want to group by <code>B</code> and extract for each group the row with the highest value of <code>C</code>. This row MUST be chosen between all the rows in each group, giving highest priority to the rows with index present in the list above.</p>
  
  <p>The result for this data and code has to be:</p>
  
  <pre><code>A       B       C
  
  A0      B0      0.5
  A2      B1      0.6
  A4      B2      1.0
  </code></pre>
  
  <p>The pseudo code for this I think has to be:</p>
  
  <pre><code>group by B
  for each group G:
      intersect group G rows index with indexes in the list
      if intersection is not void:
          the group G becomes the intersection
      sort the rows by C in ascending order
      take the first row as representative for this group
  </code></pre>
  
  <p>How can I do it in pandas?</p>
  
  <p>Thanks</p>