class_docstr: Stores all actual data and typing information for an entityset
  
  Attributes:
      id
      dataframe_dict
      relationships
      time_type
  
  Properties:
      metadata
class_docstr_tok: ["Stores","all","actual","data","and","typing","information","for","an","entityset","Attributes",":","id","dataframe_dict","relationships","time_type","Properties",":","metadata"]
docstr: Filter a dataframe for all instances before time_last.
  If the dataframe does not have a time index, return the original
  dataframe.
docstr_tok: ["Filter","a","dataframe","for","all","instances","before","time_last",".","If","the","dataframe","does","not","have","a","time","index",",","return","the","original","dataframe","."]
code: def _handle_time(
      self,
      dataframe_name,
      df,
      time_last=None,
      training_window=None,
      include_cutoff_time=True,
  ):
      """
      Filter a dataframe for all instances before time_last.
      If the dataframe does not have a time index, return the original
      dataframe.
      """
  
      schema = self[dataframe_name].ww.schema
      if is_instance(df, ps, "DataFrame") and isinstance(
          time_last, np.datetime64
      ):
          time_last = pd.to_datetime(time_last)
      if schema.time_index:
          df_empty = df.empty if isinstance(df, pd.DataFrame) else False
          if time_last is not None and not df_empty:
              if include_cutoff_time:
                  df = df[df[schema.time_index] <= time_last]
              else:
                  df = df[df[schema.time_index] < time_last]
              if training_window is not None:
                  training_window = _check_timedelta(training_window)
                  if include_cutoff_time:
                      mask = (
                          df[schema.time_index]
                          > time_last - training_window
                      )
                  else:
                      mask = (
                          df[schema.time_index]
                          >= time_last - training_window
                      )
                  lti_col = schema.metadata.get("last_time_index")
                  if lti_col is not None:
                      if include_cutoff_time:
                          lti_mask = (
                              df[lti_col] > time_last - training_window
                          )
                      else:
                          lti_mask = (
                              df[lti_col] >= time_last - training_window
                          )
                      mask = mask | lti_mask
                  else:
                      warnings.warn(
                          "Using training_window but last_time_index is "
                          "not set for dataframe %s" % (dataframe_name),
                      )
  
                  df = df[mask]
  
      secondary_time_indexes = (
          schema.metadata.get("secondary_time_index") or {}
      )
      for (
          secondary_time_index,
          columns,
      ) in secondary_time_indexes.items():
          # should we use ignore time last here?
          df_empty = df.empty if isinstance(df, pd.DataFrame) else False
          if time_last is not None and not df_empty:
              mask = df[secondary_time_index] >= time_last
              if is_instance(df, dd, "DataFrame"):
                  for col in columns:
                      df[col] = df[col].mask(mask, np.nan)
              elif is_instance(df, ps, "DataFrame"):
                  df.loc[mask, columns] = None
              else:
                  df.loc[mask, columns] = np.nan
  
      return df
  
imports: import copy
  import logging
  import warnings
  from collections import defaultdict
  import numpy
  import pandas
  from woodwork import init_series
  from woodwork.logical_types import Datetime, LatLong
  from featuretools.entityset import deserialize, serialize
  from featuretools.entityset.relationship import Relationship, RelationshipPath
  from featuretools.feature_base.feature_base import _ES_REF
  from featuretools.utils.gen_utils import Library, import_or_none, is_instance
  from featuretools.utils.plot_utils import check_graphviz, get_graphviz_format, save_graph
  from featuretools.utils.wrangle import _check_timedelta
label_desc: Use image node_id 38 for calling the EntitySet obj's underlying member method code with example usage: obj._handle_time(dataframe_name, df, time_last, training_window, include_cutoff_time) and returns: df