title: Count max depending on two columns
body: <p>I have a dataframe and I want to get the max number of counts and its corresponding year for movies and series. The df is as follows:</p>
  <pre><code>df = pd.DataFrame(
       [
         (&quot;movie&quot;, &quot;2020&quot;, 45),
         (&quot;movie&quot;, &quot;2019&quot;, 37),
         (&quot;series&quot;, &quot;2018&quot;, 16),
         (&quot;series&quot;, &quot;2010&quot;, 45),
      ],
  columns=(&quot;type&quot;, &quot;year&quot;, &quot;count&quot;),
   )
  </code></pre>
  <p>What I've tried:</p>
  <pre><code>df[df['type'] == &quot;series&quot;].max()
  df[df['type'] == &quot;movie&quot;].max()
  </code></pre>
  <p>However this does not seem to work well as it returns the max year and max count. As for example, for the series one, it will return:</p>
  <pre><code>type     series
  year       2018
  count        45
  dtype: object
  </code></pre>
  <p>and it should return:</p>
  <pre><code>type     series
  year       2010
  count        45
  dtype: object
  </code></pre>
  <p>How should I build my query so it returns the highest count with its corresponding year?</p>
  <p>Thank you</p>