code: def build_regrets_frame(
      experiments, names=None, with_evc_tree=True, order_by="suggested"
  ):
      """Builds the dataframe for regrets plot"""
      frames = []
      average_key = "best,duration"
      group = "order"
      x = group
      x_title = f"Trials ordered by {order_by} time"
      y = "best"
      for i, experiment in enumerate(experiments):
          df = experiment.to_pandas(with_evc_tree=with_evc_tree)
          df = df.loc[df["status"] == "completed"]
          df = df.sort_values(order_by)
          if len(df) > experiment.max_trials:
              df = df.head(experiment.max_trials)
          df = orion.analysis.regret(df)
  
          start = df["suggested"][0]
          durations = [t.seconds + 1 for t in (df["completed"] - start)]
          df["duration"] = durations
          df["n_workers"] = experiment.executor.n_workers
  
          df["name"] = [
              names[i]
              if names
              else f"{experiment.name}-v{experiment.version}"
          ] * len(df)
          df[group] = list(range(len(df)))
          frames.append(df)
  
      return pd.concat(frames), group, average_key, x, y, x_title
  
imports: import functools
  from collections.abc import Iterable
  import numpy
  import pandas
  import plotly.express
  import plotly.graph_objects
  from plotly.subplots import make_subplots
  import orion.analysis
  import orion.analysis.base
  from orion.algo.space import Categorical, Fidelity
  from orion.core.worker.transformer import build_required_space
label_desc: Use image node_id 8 for calling a global function with example usage: build_regrets_frame(experiments, names, with_evc_tree, order_by) and returns: pd,  group,  average_key,  x,  y,  x_title