If I have two dataframes (or series) that are already sorted on compatible keys, I'd like to be able to cheaply merge them together and maintain sortedness. I can't see a way to do that other than via concat() and explicit sort()
a = pd.DataFrame([0,1,2,3], index=[1,2,3,5], columns=['x'])
b = pd.DataFrame([4,5,6,7], index=[0,1,4,6], columns=['x'])
print pd.concat([a,b])
print pd.concat([a,b]).sort()
x
1 0
2 1
3 2
5 3
0 4
1 5
4 6
6 7
x
0 4
1 0
1 5
2 1
3 2
4 6
5 3
6 7
It looks like there has been a bit of related discussion with numpy arrays, suggesting an 'interleave' method, but I haven't found a good answer.