code: def vegalite(line, cell):
      """Cell magic for displaying vega-lite visualizations in CoLab.
  
      %%vegalite [dataframe] [--json] [--version='v5']
  
      Visualize the contents of the cell using Vega-Lite, optionally
      specifying a pandas DataFrame object to be used as the dataset.
  
      if --json is passed, then input is parsed as json rather than yaml.
      """
      args = magic_arguments.parse_argstring(vegalite, line)
      existing_versions = {"v5": "5"}
      version = existing_versions[args.version]
      assert version in RENDERERS["vega-lite"]
      VegaLite = RENDERERS["vega-lite"][version]
      data_transformers = TRANSFORMERS["vega-lite"][version]
  
      if args.json:
          spec = json.loads(cell)
      elif not YAML_AVAILABLE:
          try:
              spec = json.loads(cell)
          except json.JSONDecodeError as err:
              raise ValueError(
                  "%%vegalite: spec is not valid JSON. "
                  "Install pyyaml to parse spec as yaml"
              ) from err
      else:
          spec = yaml.load(cell, Loader=yaml.SafeLoader)
  
      if args.data is not None:
          data = _get_variable(args.data)
          spec["data"] = _prepare_data(data, data_transformers)
  
      return VegaLite(spec)
  
file_path: altair/altair/_magics.py
imports: import json
  import warnings
  import IPython
  from IPython.core import magic_arguments
  import pandas
  from toolz import curried
  from altair.vegalite import v5
label_desc: Use image node_id 3 for calling a global function with example usage: vegalite(line, cell) and returns: VegaLite