mege in pandas and flag merged cells code example Example: pandas merge sort columns result = df1.merge(df2, how='outer').sort_index(axis=1)