pandas dataframe sort rows alphabetically code example Example: sort columns dataframe df = df.reindex(sorted(df.columns), axis=1)