Mar Mar - 6 months ago 36
Python Question

Sort weightly a dataframe according to two columns

I have a pandas dataframe and i want to order it based in two columns. With

df.sort_values(['col1', 'col2'], ascending=False)
it sorts first with the col1 and then with col2. However what I wanted to do is to sort giving the same importance to both columns which is the sort was done taking into account both columns instead of one first and then the other one. How can I do this ?

Edit: col1 is float and represents a percentage and col2 is also a float but its not a percentage

Wen Wen
Answer Source

Try this ?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download