Although I have searched a lot on stackoverflow I could not find an appropriate answer for my problem. It is quite tricky because I want to extract which players where matched in a group together and store the value in a new column. I have 6 Groups, each consisting of 5 Players, over 20 Periods. Every period Players are randomly shuffled into a new Group. I want to copy 5 row values within the same column (Player ID) in an increasing order into a new column "Unique_GroupID" if and only if they they are in the same Group and Period. The idea behind this player id sorting is to check whether people were in the same Group before or not. In total, I have three columns: PlayerID; Group; Period
Ideally, the output "Unique_GroupID" should look like this:
df
PlayerID Group Period Unique_GroupID
A1 1 1 A1-A2-A3-A4-A5
A2 1 1 A1-A2-A3-A4-A5
A3 1 1 A1-A2-A3-A4-A5
A4 1 1 A1-A2-A3-A4-A5
A5 1 1 A1-A2-A3-A4-A5
B1 2 1 B1-B2-B3-B4-B5
B2 2 1 B1-B2-B3-B4-B5
B3 2 1 B1-B2-B3-B4-B5
B4 2 1 B1-B2-B3-B4-B5
B5 2 1 B1-B2-B3-B4-B5
.
.
.
.
.
.
A1 1 2 A1-B2-B3-A4-A5
A5 1 2 A1-B2-B3-A4-A5
B3 1 2 A1-B2-B3-A4-A5
A4 1 2 A1-B2-B3-A4-A5
B2 1 2 A1-B2-B3-A4-A5
B1 2 2 B1-A2-A3-B4-B5
B4 2 2 B1-A2-A3-B4-B5
B5 2 2 B1-A2-A3-B4-B5
A3 2 2 B1-A2-A3-B4-B5
A2 2 2 B1-A2-A3-B4-B5
Any ideas? Help would be very much appreciated. Thanks a lot in advance!