The sample data is :
import pandas as pd
import numpy as np
d=pd.DataFrame({'lender':['tony','wood','tony','tidy'],
                'borrower':['wood','tony','wood','tony']})
I want to connect lender and borrower and most importantly sort them within each row. In a word, I want get P:
The sort principle is the same as the default sorted function. For example:
sorted(['tony','wood'])
Out[221]: ['tony', 'wood']
sorted(['wood','tony'])
Out[222]: ['tony', 'wood']
apply is preferred unless you have to use for loop.
Please read it clearly before you duplicate my question!!!


 
    