df = df.reindex(sorted(df.columns), axis=1) not working code example Example: pandas sort columns by name df = df.reindex(sorted(df.columns), axis=1)