How to sort the data of a Data frame in descending order in python

ipython

#1

I have created a data frame in Ipython notebook and use the sort function to sort the data frame according to columns , column are arranged in ascending order .I want to know how to arranged the column in descending order.

frame = DataFrame(np.arange(8).reshape((2, 4)), index=['three', 'one'],
.....: columns=['d', 'a', 'b', 'c'])
 frame.sort_index(axis=1)
          a b c d
 three    1 2 3 0
 one      5 6 7 4

Here the column are arranged as a,b,c,d .I want that the should arranged like d,c,b,a.


#2

@sid100158,

Use option ascending (0/1) to sort the columns of data frame in ascending or descending order. Here 1 represents ascending order whereas 0 represents descending order. Look at the below code, it will first sort the column a in ascending order then by column b on descending order.

frame.sort(['a','b'], ascending=[1,0])

Hope this helps!

Regards,
Mark