1
def moving_window(self, input_df: pd.DataFrame, previous_df: pd.DataFrame):
    comb_df = pd.concat([previous_df, input_df])
    results = pd.Series()
    for index, row in input_df.iterrows():
        start_ts = int(index) - self.duration * 1000
        current_df = comb_df.loc[(comb_df.index >= start_ts) & (comb_df.index <= int(index))]
        single_pred = self.another_function(current_df)
        if single_pred:
            results.loc[index] = single_pred
    return reults

Is there a way to convert the for loop into something more efficient ?

gammawind
  • 31
  • 6

0 Answers0