I want to add a new column in my dataframe that lists all rows of a column that have common values, but I am having troubles with it.
This is what my dataframe looks like:
| Library | Book |
|---|---|
| L1 | M45 |
| L1 | M3 |
| L2 | M45 |
| L34 | M12 |
| L5 | M45 |
| L23 | M12 |
| L4 | M3 |
| L11 | M45 |
This is how it should look like.
| Location | Connections |
|---|---|
| L1 | L2,L5, L11,L4 |
| L2 | L1,L5, L11 |
| L5 | L23 |
| L5 | L1,L2, L11 |
| L23 | L34 |
| L4 | L1 |
| L11 | L1, L2,L5 |
The new Connections column should contain all the locations over common books (which are the locations that have the same books, for each location). So, since L1 has in storage the same book as L2,L5, L11 and L4, they should be added in the new column.
Thanks!