I have a large data set that looks something like this:
| ID | partner's ID |
| G | |
| H | P |
| J | |
| K | L |
| L | K |
| M | |
| N | |
| P | H |
| etc... | |
I want to split this dataset randomly to carry out an AB test for a mailing. However, I want to ensure that if someone has a partner, they and their partner end up in the same segment, e.g. that H and P receive the same version, and K and L receive the same version. One simple workaround would be to put all the records that have a partner into the same segment; but that wouldn't be random, and could impact the AB test results.
Any ideas how I could randomly split this data set into two, whilst still ensuring that the partnered records end up in the same sample?