import pandas as pd
s = pd.DataFrame([['b',40], ['cd',2], ['sf',20], ['sdf',30]],
columns=['a','score'])
This is the dataframe I have.I want to rank the dataframe according to the score in decreading order and then sort them accordingly.
I tried using df.rank with groupby but it didnt work.
expected output-
a score Rank
0 b 40 1.0
1 sdf 30 2.0
2 sf 20 3.0
3 cd 2 4.0