I want to sort a dataframe by two values, but I want one of the columns to be sorted in ascending order instead of the default descending. How would I do this in Python/pandas? Here is a sample of the dataframe I'm working with:
Unnamed: 0 myAUC avg_diff power avg_log2FC pct.1 pct.2 cluster gene
868 869 0.746 0.316557 0.492 0.456695 1.000 1.000 0 B2m
1163 1164 0.721 0.360352 0.442 0.519877 0.991 0.906 0 Atox1
1450 1451 0.703 0.361566 0.406 0.521629 0.999 0.922 0 Grn
733 734 0.760 0.375678 0.520 0.541989 1.000 0.998 0 H2-K1
686 687 0.766 0.385717 0.532 0.556472 1.000 1.000 0
For example, with CTRL_data.sort_values(['cluster', 'avg_log2FC'])
, I've sorted the dataframe by "cluster" (the string of zeros in the second to last column) and "avg_log2FC" (0.456, 0.519, 0.521, 0.541 0.556) - but I would like "avg_log2FC" to be sorted in the reverse order. I've looked around this site, and googled around more generally, but haven't been able to find anything. (But I've found it difficult to concisely describe my question so that may partially explain why I haven't found anything.)