code: def _ts_add_previous_target(
      df: pd.DataFrame, target: str, window: int
  ) -> pd.DataFrame:
      """
      Adds previous rows (as determined by `TimeseriesSettings.window`) into the cells of the target column.
  
      :param df: Input dataframe.
      :param target: target column name.
      :param window: value of `TimeseriesSettings.window` parameter.
  
      :return: Dataframe with new `__mdb_ts_previous_{target}` column that contains historical target context.
      """  # noqa
      if target not in df:
          return df
      previous_target_values = list(df[target])
      del previous_target_values[-1]
      previous_target_values = [None] + previous_target_values
  
      previous_target_values_arr = []
      for i in range(len(previous_target_values)):
          prev_vals = previous_target_values[max(i - window, 0) : i + 1]
          arr = [None] * (window - len(prev_vals))
          arr.extend(prev_vals)
          previous_target_values_arr.append(arr)
  
      df[f"__mdb_ts_previous_{target}"] = previous_target_values_arr
      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 5 for calling a global function with example usage: _ts_add_previous_target(df, target, window) and returns: df, df