**Disclaimer this is a simplified example, in the real case I need to compute a heavy cost function avoiding repetition a + b == b + a counts as duplicated**

I have a dataframe with a string column, in this example I simply add them up:

```
import pandas as pd
data = pd.DataFrame({'people':['foo','bar','baz','qux']})

```

For every name, I add any other name in the dataframe:

```
results = []
for _,r in data.iterrows():
    all_people = data['people'].tolist()
    person = r['people']
    results.append({'combination':[person+n for n in all_people]})

```

After some manipulation:

```
d = pd.DataFrame(results)
d.explode('combination')

```

I obtain

```
|    | combination   |
|---:|:--------------|
|  0 | foofoo        |
|  0 | foobar        |
|  0 | foobaz        |
|  0 | fooqux        |
|  1 | barfoo        |
|  1 | barbar        |
|  1 | barbaz        |
|  1 | barqux        |
|  2 | bazfoo        |
|  2 | bazbar        |
|  2 | bazbaz        |
|  2 | bazqux        |
|  3 | quxfoo        |
|  3 | quxbar        |
|  3 | quxbaz        |
|  3 | quxqux        |

```

For my logic foo+bar is the same as far+boo and with a very large dataframe that is a problem so ideally if I would like that once I have computed all combinations using foo to remove it from all\_people but feels ugly, is there a more pythonic way