title: How to group data while keeping all rows with max values Python
body: <p>This does not look hard but have not been able to find a solution. I have a df that looks like:</p>
  <pre><code>df = {'Name': ['MIR-10','MIR-10','LET-7','LET-7','LET-7','MIR-142','MIR-142','MIR-142'],
       'Type':['3prime','3prime','3prime','5prime','5prime','3prime','5prime','3prime']}
  df = pd.DataFrame(data=df)
  print(df)
  
        Name    Type
  0   MIR-10  3prime
  1   MIR-10  3prime
  2    LET-7  3prime
  3    LET-7  5prime
  4    LET-7  5prime
  5  MIR-142  3prime
  6  MIR-142  5prime
  7  MIR-142  3prime
  </code></pre>
  <p>I calculated the frequency of each <code>Type</code> for each element in <code>Name</code> using <code>groupby()</code> as below:</p>
  <pre><code>df['count'] = df.groupby(['Name','Type'])['Type'].transform('count')
  print(df)
  
        Name    Type  count
  0   MIR-10  3prime      2
  1   MIR-10  3prime      2
  2    LET-7  3prime      1
  3    LET-7  5prime      2
  4    LET-7  5prime      2
  5  MIR-142  3prime      2
  6  MIR-142  5prime      1
  7  MIR-142  3prime      2
  </code></pre>
  <p>Then what I would like to do <code>(in a SIMPLE solution)</code> is to keep the df if the <code>count</code> column is the maximum value for columns <code>Name</code> and <code>Type</code>.  The desired output should look like:</p>
  <pre><code>      Name    Type  count
  0   MIR-10  3prime      2
  1   MIR-10  3prime      2
  2    LET-7  5prime      2
  3    LET-7  5prime      2
  4  MIR-142  3prime      2
  5  MIR-142  3prime      2
  </code></pre>
  <p>I tried in several ways (like below) but could not get the target output.</p>
  <pre><code>df = df.groupby(['Name','Type'])['count'].transform(max)
  print(df)
  </code></pre>
  <p>Thank you in advance.</p>