title: pandas - Getting multiple maximum values
body: <p>I have a dataframe looks like this:</p>
  <pre><code>indx   user_id     type        date
  0      123          A Level-1  2021-01-15
  1      123          A Level-1  2021-01-10
  2      123          A Level-2  2021-01-10
  3      123          B Level-2  2021-01-11
  4      123          not_ctrgzd 2021-01-10
  5      124          A Level-2  2021-02-11
  6      124          B Level-1  2021-01-21
  7      124          B Level-1+ 2021-02-11
  8      125          not_ctrgzd 2021-01-31
  9      126          A Level-1  2021-02-02
  ...
  </code></pre>
  <p>What I need is to get the rows with the most recent dates for each unique type, i.e.</p>
  <pre><code>indx   user_id     type        date
  0      123          A Level-1  2021-01-15
  2      123          A Level-2  2021-01-10
  3      123          B Level-2  2021-01-11
  4      123          not_ctrgzd 2021-01-10
  5      124          A Level-2  2021-02-11
  6      124          B Level-1  2021-01-21
  7      124          B Level-1+ 2021-02-11
  8      125          not_ctrgzd 2021-01-31
  9      126          A Level-1  2021-02-02
  </code></pre>
  <p>And following code block is doing that</p>
  <pre><code>idx = df.groupby(['user_id','type'])['date'].transform(max) == df['date']
  df[idx]
  </code></pre>
  <p>Now, what I can't do is to get the rows with max type value for each type(<code>A</code>,<code>B</code> and so on) so that in the end, dataframe looks like this.</p>
  <pre><code>indx   user_id     type        date
  2      123          A Level-2  2021-01-10
  3      123          B Level-2  2021-01-11
  4      123          not_ctrgzd 2021-01-10
  5      124          A Level-2  2021-02-11
  7      124          B Level-1+ 2021-02-11
  8      125          not_ctrgzd 2021-01-31
  9      126          A Level-1  2021-02-02
  </code></pre>
  <p>Because B Level-1+ is greater than B Level-1 and A Level-2 is greater than A Level-1 and so on. Please notice that some rows have no categorized types(<code>no_ctgrzd</code>) which should be included in the final dataframe no matter what. Please do not hesitate to correct any parts that does not looks reasonable to you like the title :). Thanks!</p>