code: def _type_to_format(data_or_schema):
      """Deconstructs data passed in by the user into a standard format:
  
      - A :obj:`list` of dicts, each of which represents a single row.
      - A dict of :obj:`list`s, each of which represents a single column.
  
      Schemas passed in by the user are preserved as-is.
      :class:`pandas.DataFrame`s are flattened and returned as a columnar
      dataset.  Finally, an integer is assigned to represent the type of the
      dataset to the internal engine.
  
      Returns:
          :obj:`int`: type
                  - 0: records (:obj:`list` of :obj:`dict`)
                  - 1: columns (:obj:`dict` of :obj:`str` to :obj:`list`)
                  - 2: schema (dist[str]/dict[type])
          :obj:`list`: column names
          ():obj:`list`/:obj:`dict`): processed data
      """
      if isinstance(data_or_schema, list):
          # records
          names = (
              list(data_or_schema[0].keys())
              if len(data_or_schema) > 0
              else []
          )
          return False, 0, names, data_or_schema
      elif isinstance(data_or_schema, dict):
          # schema or columns
          for v in data_or_schema.values():
              if isinstance(v, type) or isinstance(v, str):
                  # schema maps name -> type
                  return (
                      False,
                      2,
                      list(data_or_schema.keys()),
                      data_or_schema,
                  )
              elif isinstance(v, list):
                  # a dict of iterables = type 1
                  return (
                      False,
                      1,
                      list(data_or_schema.keys()),
                      data_or_schema,
                  )
              else:
                  # See if iterable
                  try:
                      iter(v)
                  except TypeError:
                      raise NotImplementedError(
                          "Cannot load dataset of non-iterable type: Data passed in through a dict must be of type `list` or `numpy.ndarray`."
                      )
                  else:
                      return (
                          isinstance(v, numpy.ndarray),
                          1,
                          list(data_or_schema.keys()),
                          data_or_schema,
                      )
      elif isinstance(data_or_schema, numpy.ndarray):
          # structured or record array
          if not isinstance(data_or_schema.dtype.names, tuple):
              raise NotImplementedError(
                  "Data should be dict of numpy.ndarray or a structured array."
              )
          flattened = _flatten_structure(data_or_schema)
          return True, 1, list(flattened.keys()), flattened
      else:
          if not (
              isinstance(data_or_schema, pandas.DataFrame)
              or isinstance(data_or_schema, pandas.Series)
          ):
              # if pandas not installed or is not a dataframe or series
              raise NotImplementedError(
                  "Invalid data format `{}` - Data must be dataframe, dict, list, numpy.recarray, or a numpy structured array.".format(
                      type(data_or_schema)
                  )
              )
          else:
              # flatten column/index multiindex
              df, _ = deconstruct_pandas(data_or_schema)
              return (
                  True,
                  1,
                  df.columns.tolist(),
                  {c: df[c].values for c in df.columns},
              )
  
imports: from distutils.util import strtobool
  from math import isnan
  import numpy
  import pandas
  from ..core.data import deconstruct_numpy, deconstruct_pandas, make_null_mask
  from ..core.data.pd import _parse_datetime_index
  from ..core.exception import PerspectiveError
  from ._date_validator import _PerspectiveDateValidator
  from .libpsppy import t_dtype
label_desc: Use image node_id 2 for calling a global function with example usage: _type_to_format(data_or_schema) and returns: False,  int,  names,  data_or_schema, True,  int,  list,  flattened, False,  int,  list,  data_or_schema, True,  int,  df,  unknown, False,  int,  list,  data_or_schema, isinstance,  int,  list,  data_or_schema