docstr: Prepares a dataframe for the model according to what neuralforecast expects.
  
  If a per-group boundary exists, this method additionally drops out all observations prior to the cutoff.
docstr_tok: ["Prepares","a","dataframe","for","the","model","according","to","what","neuralforecast","expects",".","If","a","per-group","boundary","exists",",","this","method","additionally","drops","out","all","observations","prior","to","the","cutoff","."]
code: def _make_initial_df(self, df, mode="inference"):
      """
      Prepares a dataframe for the model according to what neuralforecast expects.
  
      If a per-group boundary exists, this method additionally drops out all observations prior to the cutoff.
      """  # noqa
  
      oby_col = self.ts_analysis["tss"].order_by
      # df = df.sort_values(by=f'__mdb_original_{oby_col}')  # TODO rm
      df[f"__mdb_parsed_{oby_col}"] = df.index
      df = df.reset_index(drop=True)
  
      Y_df = pd.DataFrame()
      Y_df["_index"] = np.arange(len(df))
      Y_df["y"] = df[self.target]
      Y_df["ds"] = df[f"__mdb_parsed_{oby_col}"]
  
      if self.grouped_by != ["__default"]:
          Y_df["unique_id"] = df[self.grouped_by].apply(
              lambda x: ",".join([elt for elt in x]), axis=1
          )
      else:
          Y_df["unique_id"] = "__default"
  
      Y_df = Y_df.reset_index()
  
      # filter if boundary exists
      if mode == "train" and self.group_boundaries:
          filtered = []
          grouped = Y_df.groupby(by="unique_id")
          for group, sdf in grouped:
              if group in self.group_boundaries:
                  sdf = sdf[sdf["ds"].gt(self.group_boundaries[group])]
                  if sdf.shape[0] > 0:
                      filtered.append(sdf)
          if filtered:
              Y_df = pd.concat(filtered)
  
      filtered_idxs = Y_df.pop("_index").values
      return Y_df, filtered_idxs
  
file_path: lightwood/lightwood/mixer/nhits.py
imports: from typing import Dict, Union, Optional
  from copy import deepcopy
  import numpy
  import pandas
  from neuralforecast import NeuralForecast
  from neuralforecast.models.nhits import NHITS
  from neuralforecast.models.nbeats import NBEATS
  from neuralforecast.losses.pytorch import MQLoss
  from lightwood.helpers.log import log
  from lightwood.mixer.base import BaseMixer
  from lightwood.api.types import PredictionArguments
  from lightwood.data.encoded_ds import EncodedDs, ConcatedEncodedDs
label_desc: Use image node_id 5 for calling the NHitsMixer obj's underlying member method code with example usage: obj._make_initial_df(df, mode) and returns: Y_df,  filtered_idxs