def get_events(self, event_names):
    """Get all events as pandas DataFrames given a list of names.
    Args:
      event_names: A list of events to get.
    Returns:
      A list with the same length and order as event_names. Each element is a dictionary
          {dir1: DataFrame1, dir2: DataFrame2, ...}.
          Multiple directories may contain events with the same name, but they are different
          events (i.e. 'loss' under trains_set/, and 'loss' under eval_set/.)
    """

    if isinstance(event_names, six.string_types):
      event_names = [event_names]

    all_events = self.list_events()
    dirs_to_look = set()
    for event, dirs in six.iteritems(all_events):
      if event in event_names:
        dirs_to_look.update(dirs)

    ret_events = [collections.defaultdict(lambda: pd.DataFrame(columns=['time', 'step', 'value']))
                  for i in range(len(event_names))]
    for event_file in self._glob_events_files(dirs_to_look, recursive=False):
      try:
        for record in tf_record.tf_record_iterator(event_file):
          event = event_pb2.Event.FromString(record)
          if event.summary is None or event.wall_time is None or event.summary.value is None:
            continue

          event_time = datetime.datetime.fromtimestamp(event.wall_time)
          for value in event.summary.value:
            if value.tag not in event_names or value.simple_value is None:
              continue

            index = event_names.index(value.tag)
            dir_event_dict = ret_events[index]
            dir = os.path.dirname(event_file)
            # Append a row.
            df = dir_event_dict[dir]
            df.loc[len(df)] = [event_time, event.step, value.simple_value]
      except tf.errors.DataLossError:
        # DataLossError seems to happen sometimes for small logs.
        # We want to show good records regardless.
        continue

    for idx, dir_event_dict in enumerate(ret_events):
      for df in dir_event_dict.values():
        df.sort_values(by=['time'], inplace=True)
      ret_events[idx] = dict(dir_event_dict)

    return ret_events
Get all events as pandas DataFrames given a list of names.
    Args:
      event_names: A list of events to get.
    Returns:
      A list with the same length and order as event_names. Each element is a dictionary
          {dir1: DataFrame1, dir2: DataFrame2, ...}.
          Multiple directories may contain events with the same name, but they are different
          events (i.e. 'loss' under trains_set/, and 'loss' under eval_set/.)