I have a Dataframe
as below:
df = pd.DataFrame({\'first\' : [\'John\', \'Mary\',\'Peter\'],
\'last\' : [\'Mary\', \'John\',\'
In [13]: pd.DataFrame(np.sort(df.values, axis=1), columns=df.columns).drop_duplicates()
Out[13]:
first last
0 John Mary
2 Mary Peter
or:
In [18]: df.values.sort(axis=1) # NOTE: it sorts DF in-place
In [19]: df
Out[19]:
first last
0 John Mary
1 John Mary
2 Mary Peter
In [20]: df.drop_duplicates()
Out[20]:
first last
0 John Mary
2 Mary Peter