code: def unpivot_frame(
      frame, x=None, y=None, var_name="variable", value_name="value"
  ):
      """Unpivot a dataframe for use with Vega/Vega-Lite
  
      The input is a frame with any number of columns,
      output is a frame with three columns: x value, y values,
      and variable names.
      """
      if x is None:
          cols = frame.columns
          frame = frame.reset_index()
          x = (set(frame.columns) - set(cols)).pop()
      # frame.melt doesn't properly check for nonexisting columns, so we
      # start by indexing here. Tuples of column names also need to be
      # converted to lists for checking indexing
      if isinstance(x, tuple):
          x = list(x)
      if isinstance(y, tuple):
          y = list(y)
      if x is not None:
          _ = frame[x]  # noqa
      if y is not None:
          _ = frame[y]  # noqa
      return frame.melt(
          id_vars=x,
          value_vars=y,
          var_name=var_name,
          value_name=value_name,
      )
  
file_path: pdvega/pdvega/_utils.py
imports: import warnings
  import numpy
  import pandas
  from ._pandas_internals import infer_dtype
  from ._pandas_internals import _infer_dtype_kwds
label_desc: Use image node_id 2 for calling a global function with example usage: unpivot_frame(frame, x, y, var_name, value_name) and returns: frame