'Slicing Dataframe according to other Dataframe, performing calculations based on those slices

Given are 2 dataframes. Lets say one includes 100,000 rows, and the other one 100 rows. The shorter df provides in each row, a start and end time that corresponds to index on the larger df. First, I need to slice the first one according to those 100 different time stamps given in the second one. After that, I have to apply a function to those rows inside the time stamps, but only those, not the ones outside a timestamp. Then, I have to calculate the difference between the actual values and the ones that resulted from the function. Currently, I am using iterrows, but this is obviously a really slow solution.

Any other suggestions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source