code: def to_pandas(data: dict) -> Union[Matrix, Vector, Scalar, String]:
      """Convert Prometheus data object to Pandas object."""
      result_type = data["resultType"]
      if result_type == "vector":
          return pd.Series(
              (np.float64(r["value"][1]) for r in data["result"]),
              index=(metric_name(r["metric"]) for r in data["result"]),
          )
      elif result_type == "matrix":
          return pd.DataFrame(
              {
                  metric_name(r["metric"]): pd.Series(
                      (np.float64(v[1]) for v in r["values"]),
                      index=(
                          pd.Timestamp(v[0], unit="s")
                          for v in r["values"]
                      ),
                  )
                  for r in data["result"]
              }
          )
      elif result_type == "scalar":
          return np.float64(data["result"])
      elif result_type == "string":
          return data["result"]
      else:
          invalidInputError(
              False,
              f"The collected Prometheus data is unknown type {result_type}.",
          )
  
file_path: BigDL/python/chronos/src/bigdl/chronos/data/utils/prometheus_df.py
imports: import datetime
  import json
  from typing import Optional, Union
  from urllib.parse import urljoin
  import numpy
  import pandas
  import requests
  from bigdl.nano.utils.common import invalidInputError
label_desc: Use image node_id 1 for calling a global function with example usage: to_pandas(data) and returns: pd, pd, np, data