My dataset df
look like this:
date high
2018-01-01 -1
2018-01-02 1
2018-01-03 -2
2018-01-04 0
...., ....
2018-12-31 1
Where,
-2 >= high <= 2
high
is always between -2
and 2
I want to sort the value of high
in the following pattern:
To start, Group all 0
and sort by date and so on for other values.
Sort the high
value in the following order:
0
1
-1
2
-2
It would be best if it's flexible enough that I can change the order if required.
I know how to sort in asc
or desc
by doing this:
df.sort_values(by='high', ascending=False)
Could you please help me solve how do I sort using predetermined values?