I would like to find duplicate values across rows. e.g. row 1 has 3 duplicates (A). Keep the first value (or keep any one of them), and replace the other duplicate values with nan
| col1 | col2 | col3. | col4 | |
|---|---|---|---|---|
| 1 | A | A | A | Y |
| 2 | B | D | G | L |
| 3 | E | F | T | K |
data = {'col1':['A', 'B', 'E'],
'col2':['A', 'D', 'F'],
'col3':['A', 'G', 'T'],
'col4':['Y', 'L', 'K']}
# Create DataFrame
df = pd.DataFrame(data)
Thank you.