Pandas sort_index numerically, not lexicographically
You might have the index as a string type.
I was having this issue after using the groupby() function. I fixed the problem by changing the column that later became my index to an int() with:
df['col_name'] = df['col_name'].astype(int) .
I'm having some issues with sorting a pandas dataframe.
sort_index(axis=0) results in the dataframe sorting the index as 1 10 11 12 13... etc.
While sort_index(axis=1) seems to work for the first couple of rows and then it gets completely disordered.
I simply cannot wrap my head around what is going on. I want a simply numerical sorting of my indices, it seems that it ought to be the standard setting for sort_index.