Question: How to sort index and column data by ascending order in python So far I have the percentages sorted, but now I need to fix

How to sort index and column data by ascending order in python

So far I have the percentages sorted, but now I need to fix the indexes, need to reset the index of df so that the highest sugarpercent candy is index 0.

How to sort index and column data by ascending order in python

In [222]: # YOUR CODE HERE df = df.sort_values('sugarpercent', ascending=False) print(df) sugarpercent chocolate winpercent pricepercent 0.988 1 72.887901 0.651 0.965 1 64.353340 0.860 0.941 0 55.103695 0.220 0.941 0 63.085140 0.220 0.906 0 52.341465 0.511 0 0.069 0.069 0.046 0.046 0.034 52.825947 59.863998 39.141056 24.524988 81.866257 0.116 0.116 0.104 0.325 0.279 0 1 1 competitorname fruity hard multicandy_pack bar 54 Reeses stuffed with pieces Milky Way Simply Caramel Skittles wildberry Skittles original 10 Air Heads 1 0 1 0 Sour Patch Tricksters Sour Patch Kids Lemonhead Chiclets

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!