pandas df sort column names code example
Example 1: pandas sort columns by name
df = df.reindex(sorted(df.columns), axis=1)
Example 2: python dataframe sort by column name
>>> result = df.sort(['A', 'B'], ascending=[1, 0])
df = df.reindex(sorted(df.columns), axis=1)
>>> result = df.sort(['A', 'B'], ascending=[1, 0])