title: Returning a value_counts() column when using nlargest()
body: <p>I am returning the ratings of features for a business by demographic and ratings conditions. I would like to include the variable names used in the value counts output. Specifically, how do I include the variable name <code>Design</code> in the output?</p>
  <br>
  <pre><code># Cols I want to see the ratings for
  ranked_cols = [
      &quot;Design&quot;,
      &quot;Food&quot;,
      &quot;Wi-Fi&quot;,
      &quot;Service&quot;,
  ]
  
  # Select the relevant customers
  sub = df[
      (df[&quot;Customer Type&quot;] == &quot;Disloyal&quot;)
      &amp; (df[&quot;Satisfaction&quot;] == &quot;Not Satisfied&quot;)
      &amp; df[&quot;Age&quot;].between(30, 40)
  ]
  
  (
      sub.melt(value_vars=ranked_cols)
      .groupby(&quot;variable&quot;)
      .value_counts()
      .to_frame()
      .reset_index()
      .rename(columns={&quot;value&quot;: &quot;rating&quot;, 0: &quot;count&quot;})
  )
  
  [Out]
  
      variable  rating  count
  0   Design    2       5
  1   Food      0       1 
  2   Service   4       1
  3   Wi-Fi     2       3
  </code></pre>
  <p>If I assign the melt to a variable e.g. <code>prod=( sub.melt(value_vars=ranked_cols)</code>, I can query the product with the highest count of 2 ratings, but it does not return the variable name <code>Design</code>:</p>
  <pre><code>prods[prods.rating == 2]['count'].nlargest(1)
  
  [Out]
  
  2     5
  
  Name: count, dtype: int64
  </code></pre>