This is my dataframe:
df = pd.read_csv('https://raw.githubusercontent.com/AmirForooghi/stocks_example/main/xxx.csv')
I want to sort df by two columns: rsi and sector. For rsi I want ascending=False and for sector I want to use the key argument. The key is:
order_dic = {j: i for i, j in enumerate(['bank', 'naft', 'pey'])}
What I have tried so far is:
df = df.loc[df.sector.isin(['bank', 'naft', 'pey'])] # just to clean the data a little bit
sorted_df = df.sort_values(by='rsi', ascending=False).sort_values(by='sector', key=lambda x:x.map(order_dic))
But it doesn't work. it is sorted by the key correctly but it is not sorted by rsi.