I'm trying to sort data by two columns. One of them by absolute value. It is easy to sort values by two columns http://pandas.pydata.org/pandas-docs/version/0.17/generated/pandas.DataFrame.sort_values.html and by abs value Sort by absolute value for one column, but I can't merge both approaches.
for instance, I have df that already ordered by abs 'dist' and then I want to sort it internally by 'taking'
In[4]:df
Out[4]: 
        q_id  dist  taking
    0   406   6.0    0.17
    1   448   6.0    0.46
    2   449   6.0    0.42
    3   208  -6.0    0.25
    4   244  -7.0    0.12
    5   203   7.0    0.40
    6   614   8.0    0.50
    7   243  -8.0    0.40
it may look like this
df_sorted
Out[]: 
        q_id  dist  taking
    1   448   6.0    0.46
    2   449   6.0    0.42
    3   208  -6.0    0.25
    0   406   6.0    0.17
    4   244  -7.0    0.12
    5   203   7.0    0.40
    6   614   8.0    0.50
    7   243  -8.0    0.40
Ascending=[True, False] is also required but I hope it shouldn't be a problem.
Does anyone know how to sort that DataFrame?
 
    