How can I rank a DataFrame based on 2 columns?
On below example, col_b
would the tie breaker for col_a
.
DataFrame:
df = pd.DataFrame({'col_a':[0,0,0,1,1,1], 'col_b':[5,2,8,3,7,4]})
df
col_a col_b
0 0 5
1 0 2
2 0 8
3 1 3
4 1 7
5 1 4
Expected Output:
col_a col_b Rank
0 0 5 2
1 0 2 1
2 0 8 3
3 1 3 4
4 1 7 6
5 1 4 5