I'm trying to remove duplicate elements in column 'p1' and 'p2' i.e should the elements already occurred in column 'p1' it should not reappear in 'p2' or any subsequent column. For eg, for the code below, only 'a b' and 'c d' will remain.
Whats the effecient way of doing this?
import pandas as pd
df = pd.DataFrame({'p1':['a','b','a','a','b','d','c'],
'p2':['b','a','c','d','c','a','d'],
'value':[1,1,2,3,5,3,5]})
df