code: def add_date_time_features(
      smalldf,
      startTime,
      endTime,
      splitter_date_string="/",
      splitter_hour_string=":",
  ):
      """
      If you have start date time stamp and end date time stamp, this module will create additional features for such fields.
      You must provide a start date time stamp field and if you have an end date time stamp field, you must use it.
      Otherwise, you are better off using the create_date_time_features module which is also in this library.
      You must provide the following:
      smalldf: Dataframe containing your date time fields
      startTime: this is hopefully a string field which converts to a date time stamp easily. Make sure it is a string.
      endTime: this also must be a string field which converts to a date time stamp easily. Make sure it is a string.
      splitter_date_string: usually there is a string such as '/' or '.' between day/month/year etc. Default is assumed / here.
      splitter_hour_string: usually there is a string such as ':' or '.' between hour:min:sec etc. Default is assumed : here.
      """
      smalldf = smalldf.copy()
      add_cols = []
      start_date = "processing" + startTime + "_start_date"
      smalldf[start_date] = smalldf[startTime].map(
          lambda x: x.split(" ")[0]
      )
      add_cols.append(start_date)
      try:
          start_time = "processing" + startTime + "_start_time"
          smalldf[start_time] = smalldf[startTime].map(
              lambda x: x.split(" ")[1]
          )
          add_cols.append(start_time)
      except:
          ### there is no hour-minutes part of this date time stamp field. You can just skip it if it is not there
          pass
      end_date = "processing" + endTime + "_end_date"
      smalldf[end_date] = smalldf[endTime].map(
          lambda x: x.split(" ")[0]
      )
      add_cols.append(end_date)
      try:
          end_time = "processing" + endTime + "_end_time"
          smalldf[end_time] = smalldf[endTime].map(
              lambda x: x.split(" ")[1]
          )
          add_cols.append(end_time)
      except:
          ### there is no hour-minutes part of this date time stamp field. You can just skip it if it is not there
          pass
      view_days = "processing" + startTime + "_elapsed_days"
      smalldf[view_days] = (
          pd.to_datetime(smalldf[end_date])
          - pd.to_datetime(smalldf[start_date])
      ).values.astype(int)
      add_cols.append(view_days)
      try:
          view_time = "processing" + startTime + "_elapsed_time"
          smalldf[view_time] = (
              (
                  pd.to_datetime(smalldf[end_time])
                  - pd.to_datetime(smalldf[start_time])
              )
              .astype("timedelta64[s]")
              .values
          )
          add_cols.append(view_time)
      except:
          ### In some date time fields this gives an error so skip it in that case
          pass
      #### The reason we chose endTime here is that startTime is usually taken care of by another library. So better to do this alone.
      year = "processing" + endTime + "_end_year"
      smalldf[year] = (
          smalldf[end_date]
          .map(lambda x: str(x).split(splitter_date_string)[0])
          .values
      )
      add_cols.append(year)
      #### The reason we chose endTime here is that startTime is usually taken care of by another library. So better to do this alone.
      month = "processing" + endTime + "_end_month"
      smalldf[month] = (
          smalldf[end_date]
          .map(lambda x: str(x).split(splitter_date_string)[1])
          .values
      )
      add_cols.append(month)
      try:
          #### The reason we chose endTime here is that startTime is usually taken care of by another library. So better to do this alone.
          daynum = "processing" + endTime + "_end_day_number"
          smalldf[daynum] = (
              smalldf[end_date]
              .map(lambda x: str(x).split(splitter_date_string)[2])
              .values
          )
          add_cols.append(daynum)
      except:
          ### In some date time fields the day number is not there. If not, just skip it ####
          pass
      #### In some date time fields, the hour and minute is not there, so skip it in that case if it errors!
      try:
          start_hour = "processing" + startTime + "_start_hour"
          smalldf[start_hour] = (
              smalldf[start_time]
              .map(lambda x: str(x).split(splitter_hour_string)[0])
              .values
          )
          add_cols.append(start_hour)
          start_min = "processing" + startTime + "_start_hour"
          smalldf[start_min] = (
              smalldf[start_time]
              .map(lambda x: str(x).split(splitter_hour_string)[1])
              .values
          )
          add_cols.append(start_min)
      except:
          ### If it errors, skip it
          pass
      #### Check if there is a weekday and weekends in date time columns using endTime only
      weekday_num = "processing" + endTime + "_end_weekday_number"
      smalldf[weekday_num] = pd.to_datetime(
          smalldf[end_date]
      ).dt.weekday.values
      add_cols.append(weekday_num)
      weekend = "processing" + endTime + "_end_weekend_flag"
      smalldf[weekend] = smalldf[weekday_num].map(
          lambda x: 1 if x in [5, 6] else 0
      )
      add_cols.append(weekend)
      #### If everything works well, there should be 13 new columns added by module. All the best!
      print(
          "%d columns added using start date=%s and end date=%s processing..."
          % (len(add_cols), startTime, endTime)
      )
      return smalldf
  
file_path: Auto_ViML/autoviml/feature_engineering.py
imports: import pandas
  import numpy
  import copy
  import time
  import pdb
label_desc: Use image node_id 3 for calling a global function with example usage: add_date_time_features(smalldf, startTime, endTime, splitter_date_string, splitter_hour_string) and returns: smalldf