0

I'm trying to sort the contents of my dataframe on 'percentage'. The sort doesn't seem to work.

Code- enter image description here

ipl_tot['Win Percent'] = ipl_tot['Matches Won']/ipl_tot['Matches 
Played'] * 100
ipl_tot.sort_values(by = (['Matches Won', 'Win Percent']),ascending = 
False)
ipl_tot
Coder
  • 3
  • 3
  • You need to either re-assign the dataframe or add the `inplace=True` parameter in `sort_values` method. – FBruzzesi Mar 29 '20 at 16:39

1 Answers1

1

You have to pass in the inplace=True parameter to sort_values function to perform the operation in place.

Replace:

ipl_tot.sort_values(by=(['Matches Won', 'Win Percent']), ascending=False)

With:

ipl_tot.sort_values(by=(['Matches Won', 'Win Percent']), ascending=False, inplace=True)
Shubham Sharma
  • 68,127
  • 6
  • 24
  • 53