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?
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)
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?
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)