Given a DataFrame like this:
n name number time
0 foo 0 .1
1 foo 3 .15
2 bar 0 .2
3 bar 2 .3
4 foo 1 .4
5 foo 5 .45
6 bar 3 .5
7 bar 4 .55
8 bar 5 .6
9 bar 1 .7
Make this DataFrame:
n name number time n name number time
0 foo 0 .1 2 bar 0 .2
1 foo 3 .15 6 bar 3 .5
4 foo 1 .4 9 bar 1 .7
5 foo 5 .45 8 bar 5 .6
I've hacked together a solution using using shift that works if the data appears like this:
n name number time
0 foo 0 .1
1 bar 0 .15
2 foo 1 .2
3 bar 2 .3
4 foo 3 .4
5 bar 5 .5
But I can't guarantee that the original data interleaves 'foo' and 'bar.' I need to be able to get pairs any distance apart.