how to rearrange csv columns index 0 pandas sort_index code example Example 1: pandas sort dataframe by index df.sort_index() Example 2: how to sort index pd.sort_index()