I am grouping travellers who travel together, based on the % of trips that they take together. This seems similar to another question (Group Python list of lists into groups based on overlapping items) but the conditions are different.
The travellers are only grouped together if they travelled 80% of the trips together. It is ok if the same traveller are in different groups.
Data: (the actual dataset is big and has >1000 trips and travellers)
Traveller Trips
A [Trip_1, Trip_2, Trip_3, Trip_4, Trip_5]
B [Trip_1, Trip_2, Trip_3, Trip_4]
C [Trip_6, Trip_7]
D [Trip_8]
E [Trip_2, Trip_3, Trip_4, Trip_5]
F [Trip_2, Trip_3, Trip_4, Trip_5]
G [Trip_8]
Intended output:
TravelGroup Traveller
Group_1 A
Group_1 B
Group_2 A
Group_2 E
Group_2 F
Group_3 C
Group_4 D
Group_4 G
Note that A and B are in a group; A, E and F are in a group. However, B and C are not in a group because they only have 75% match in the trips taken.
Really appreciate any help here, thank you very much!