I have two dataframes in pandas. DF "A" contains the start and end indexes of zone names. DF "B" contains the start and end indexes of subzones. The goal is to extract all subzones of all zones.
Example:
A:
start index | end index | zone name
-----------------------------------
1 | 10 | X
B:
start index | end index | subzone name
-----------------------------------
2 | 3 | Y
In the above example, Y is a subzone of X since its indexes fall within X's indexes.
The way I'm currently doing this is using iterrows to go through every row in A, and for every row (zone) I find the slice in B (subzone). This solution is extremely slow in pandas since iterrows is not fast. How can I do this task without using iterrows in pandas?