code: def load_results(path: str) -> pandas.DataFrame:
      """
      Load all Monitor logs from a given directory path matching ``*monitor.csv`` and ``*monitor.json``
  
      :param path: (str) the directory path containing the log file(s)
      :return: (pandas.DataFrame) the logged data
      """
      # get both csv and (old) json files
      monitor_files = glob(
          os.path.join(path, "*monitor.json")
      ) + get_monitor_files(path)
      if not monitor_files:
          raise LoadMonitorResultsError(
              "no monitor files of the form *%s found in %s"
              % (Monitor.EXT, path)
          )
      data_frames = []
      headers = []
      for file_name in monitor_files:
          with open(file_name, "rt") as file_handler:
              if file_name.endswith("csv"):
                  first_line = file_handler.readline()
                  assert first_line[0] == "#"
                  header = json.loads(first_line[1:])
                  data_frame = pandas.read_csv(
                      file_handler, index_col=None
                  )
                  headers.append(header)
              elif file_name.endswith("json"):  # Deprecated json format
                  episodes = []
                  lines = file_handler.readlines()
                  header = json.loads(lines[0])
                  headers.append(header)
                  for line in lines[1:]:
                      episode = json.loads(line)
                      episodes.append(episode)
                  data_frame = pandas.DataFrame(episodes)
              else:
                  assert 0, "unreachable"
              data_frame["t"] += header["t_start"]
          data_frames.append(data_frame)
      data_frame = pandas.concat(data_frames)
      data_frame.sort_values("t", inplace=True)
      data_frame.reset_index(inplace=True)
      data_frame["t"] -= min(header["t_start"] for header in headers)
      # data_frame.headers = headers  # HACK to preserve backwards compatibility
      return data_frame
  
imports: import csv
  import json
  import os
  import time
  from glob import glob
  from typing import Tuple, Dict, Any, List, Optional
  import gym
  import pandas
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: load_results(path) and returns: data_frame