Question: I have a dataframe values like this:

```
name             foreign_name   acronym  alias
United States   États-Unis       USA     USA

```

I want to merge all those four columns in a row into one single columns 'names', so I do:

```
merge = lambda x: '|'.join([a for a in x.unique() if a])
df['names'] = df[['name', 'foreign_name', 'acronym', 'alias',]].apply(merge, axis=1)

```

The problem with this code is that, it doesn't remove the duplicate 'USA', instead it gets:

```
names = 'United States|États-Unis|USA|USA'

```

Where am I wrong?

Answer: 
MCVE:

```
import pandas as pd
import numpy as np

d= {'name': {0: 'United States'},
 'foreign_name': {0: 'États-Unis'},
 'acronym': {0: 'USA'},
 'alias': {0: 'USA'}}
df = pd.DataFrame(d)

merge = lambda x: '|'.join([a for a in x.unique() if a])
df['names'] = df[['name', 'foreign_name', 'acronym', 'alias',]].apply(merge, axis=1)
print(df)

```

Output:

```
            name foreign_name acronym alias                         names
0  United States   États-Unis     USA   USA  United States|États-Unis|USA

```
You just need to tell is to operate along row axis. `axis=1`

```
df.apply(lambda r: "|".join(r.unique()), axis=1)

```

### output

```
United    States|États-Unis|USA
dtype: object

```