Typeerror for sort

Question:

TypeError                                 Traceback (most recent call last)
<ipython-input-130-50c833fafd4b> in <module>
      1 import pandas as pd
----> 2 df_college.groupby('Name')['PercUG'].unique().sort_values(by='PercUG',ascending=False)

TypeError: sort_values() got an unexpected keyword argument 'by'

Which are the 5 colleges with highest percentage of undergraduates?

Asked By: Ajit Singh

||

Answers:

Here’s the corrected code to get the top 5 colleges with the highest percentage of undergraduates:

top_5_colleges_p = df_college.groupby('Name')['PercUG'].unique().sort_values(ascending=False).head(5)
print(top_5_colleges_p)
Answered By: Muhammed Onur Kaya
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.