sort_index by a column in pandas code example Example: pandas sort dataframe by index df.sort_index()