The idea is that this function applies a function to overlapping rows in a data frame (that is, a "rolling window"). A basic implementation is as follows:
def apply_rolling_window(df, func, window_size, progress_bar=False):
it = range(len(df))
if progress_bar:
it = tqdm.trange(len(df))
ret = [
func(df.iloc[i: i+window_size])
for i in it
]
return ret