code: def _ts_add_previous_rows(
      df: pd.DataFrame, order_cols: list, window: int
  ) -> pd.DataFrame:
      """
      Adds previous rows (as determined by `TimeseriesSettings.window`) into the cells of the `order_by` column.
  
      :param df: Input dataframe.
      :param order_cols: `order_by` column and other columns flagged as `historical`.
      :param window: value of `TimeseriesSettings.window` parameter.
  
      :return: Dataframe with all `order_cols` modified so that their values are now arrays of historical context.
      """  # noqa
      for order_col in order_cols:
          new_vals = np.zeros((len(df), window))
          for i in range(window, 0, -1):
              new_vals[:, i - 1] = (
                  df[order_col].shift(window - i).values
              )
  
          new_vals = np.nan_to_num(new_vals, nan=0.0)
          for i in range(len(df)):
              df.at[df.index[i], order_col] = new_vals[i, :]
  
      return df
  
file_path: lightwood/lightwood/data/timeseries_transform.py
imports: from typing import Dict, Optional
  from functools import partial
  import multiprocessing
  import numpy
  import pandas
  from lightwood.helpers.parallelism import get_nr_procs
  from type_infer.dtype import dtype
  from lightwood.api.types import TimeseriesSettings, PredictionArguments
  from lightwood.helpers.log import log
label_desc: Use image node_id 4 for calling a global function with example usage: _ts_add_previous_rows(df, order_cols, window) and returns: df