I have a dataframe with Datetime index that I want to sort with the last Datetime.
For example, my dataframe is:
A B C D
2018-12-05 20:12:10 48.58 50.81 46.71 48.18
2018-12-05 20:11:49 54.43 45.08 48.67 49.72
2018-12-05 20:11:41 49.86 52.40 48.47 50.02
And I want to sort it like this:
B A D C
2018-12-05 20:12:10 50.81 48.58 48.18 46.71
2018-12-05 20:11:49 45.08 54.43 49.72 48.67
2018-12-05 20:11:41 52.40 49.86 50.02 48.47
I tried:
df.sort_values(by=df.iloc[0],ascending=False,inplace=True)
and
df.sort_values(by=df.index[0],ascending=False,inplace=True)
I get the error :"Exeption Unhandled Timestamp('2018-12-05 20:12:10')"
I also tried:
df.sort_values(by=df.iloc[0],ascending=False,inplace=True, axis=1)
and
df.sort_values(by=df.index[0],ascending=False,inplace=True, axis=1)
And I got a return : "None"
My index type is 'datetime64'
Any hints will be very appreciated. Thanks!