I am experimenting with R-tree package in python. While there's a way to do nearest neighbor search, is there a way to produce the K nearest neighbors based on vertical/ horizontal distance separately?
You could create two additional data-sets, "projecting" points into each axis by removing the other coordinate. Then, you'll have transformed the problem into a 1-dimensional nearest-neighbour search.