pandas - alternative to recursive sql / dedupe columns -
hi have data set 1 many relations. want reduce 1-1 concatenating distinct values each column here example: i have data set called customer , product affiliation (pa) . 1 customer can have multiple pa different times. here input: ╔════════╦═══════╦══════╦══════╗ ║ cust ║pa1 ║ pa2 ║ pa3 ║ ╠════════╬═══════╬══════╬══════╣ ║ ║ h ║ m ║ l ║ ║ ║ h ║ l ║ m ║ ║ ║ h ║ m ║ h ║ ╚════════╩═══════╩══════╩══════╝ desired output: ╔════════╦══════╦══════════╦═══════╗ ║ cust ║ pa1 ║ pa2 ║ pa3 ║ ╠════════╬══════╬══════════╬═══════╣ ║ ║ h ║ m&l ║ l&m&h ║ ╚════════╩══════╩══════════╩═══════╝ i have multiple pa columns. want know if there generic python panda code can apply thank minc here's expanded version of sample data make more clear how code operates on groups rather whole dataframe: df = pd.dataframe({ 'cust':list('aaabbb'),'pa1':list('hhhmmh'), ...