0

I am would like to sort the values in my groupby by Actual Cost in ascending order, but I keep getting the wrong result.

This is my code:

D16 = Dec16.groupby('PRACTICE', sort=False)["Actual Cost"].sum()
D16

And it returns this:

PRACTICE
1       19585.09
3      144741.12
5       32622.69
6      138969.68
10      33973.04

Does anyone know how I can sort this correctly?

ekhumoro
  • 115,249
  • 20
  • 229
  • 336
Sarah
  • 3
  • 3
  • 7

1 Answers1

0

If your dataframe D16 looks like this with one column PRACTICE

     PRACTICE
 0   19585.09
 1  144741.12
 2   32622.69
 3  138969.68
 4   33973.04

D16.sort_values(by='PRACTICE', ascending=True)

will yield;

    PRACTICE
 0  19585.09
 2  32622.69
 4  33973.04
 3  138969.68
 1  144741.12
ababuji
  • 1,683
  • 2
  • 14
  • 39