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