dataframe merge column sort code example Example: pandas merge sort columns result = df1.merge(df2, how='outer').sort_index(axis=1)