I have a dataframe called df that is indexed by date which I am trying to sort oldest date to newest.
I have tried to use both:
df = df.sort(axis=1)
and:
df = df.sort_index(axis=1)
but as you can see from the date order in the following df tail the dates have not been sorted into date order.
wood_density
date
2016-01-27 5.8821
2016-01-28 5.7760
2015-12-25 NaN
2016-01-01 NaN
2015-12-26 NaN
What can I try to resolve this?
axis=1sorts columns;axis=0(the default) sorts rows.