code: def compare_df(tables, ids, scores_arg):
      """
      Generates a comparison from a list of tables. Taables can be either a
      pandas.DataFrame or a str with an HTML table. The output depends
      on the number of tables and rows. Returns a pandas.DataFrame with style
      added (colors)
      """
      dfs = [to_df(table) for table in tables]
  
      # Single-row data frames, each metric is a single number
      # TODO: check dims are consistent
      if len(dfs[0]) == 1:
          out = pd.concat(dfs)
          out.index = ids
          out = out.T
          errors, scores = split_errors_and_scores(
              out.index, scores_arg, axis_second=out.columns
          )
  
          if len(tables) == 2:
              c1, c2 = out.columns
              out["diff"] = out[c2] - out[c1]
              out["diff_relative"] = (out[c2] - out[c1]) / out[c2]
              out["ratio"] = out[c2] / out[c1]
  
          styled = out.style.apply(
              _color_map["error"]["max"], subset=errors, axis="columns"
          )
          styled = styled.apply(
              _color_map["error"]["min"], subset=errors, axis="columns"
          )
          styled = styled.apply(
              _color_map["score"]["max"], subset=scores, axis="columns"
          )
          styled = styled.apply(
              _color_map["score"]["min"], subset=scores, axis="columns"
          )
  
          styled = styled.format({"diff_relative": "{:.2%}"})
  
      # Multiple rows, each metric is a vector
      else:
          # we can only return a summary if dealing with two tables
          if len(tables) == 2:
              # TODO: generate "Compare diff", "Compare diff relative"
              # and "Compare ratio"
              out = dfs[1] - dfs[0]
              errors, scores = split_errors_and_scores(
                  out.columns,
                  scores_arg,
                  axis_second=out.index,
                  transpose=True,
              )
  
              styled = out.style.apply(
                  color_neg_green, subset=errors, axis="rows"
              )
              styled = styled.apply(
                  color_neg_red, subset=scores, axis="rows"
              )
          else:
              styled = None
  
      return styled
  
imports: from functools import partial
  from difflib import HtmlDiff
  import random
  import string
  import base64
  import copy
  from pathlib import Path
  from collections.abc import Mapping
  import black
  import pandas
  from IPython.display import HTML, Image
  from jinja2 import Environment, PackageLoader
  from .NotebookIntrospector import NotebookIntrospector
  from .sets import differences
  from ..table import Table
  from ..telemetry import SKLearnEvaluationLogger
label_desc: Use image node_id 14 for calling a global function with example usage: compare_df(tables, ids, scores_arg) and returns: styled