code: def convert(data, to):
      converted = None
      if to == "array":
          if isinstance(data, np.ndarray):
              converted = data
          elif isinstance(data, pd.Series):
              converted = data.values
          elif isinstance(data, list):
              converted = np.array(data)
          elif isinstance(data, pd.DataFrame):
              converted = data.as_matrix()
      elif to == "list":
          if isinstance(data, list):
              converted = data
          elif isinstance(data, pd.Series):
              converted = data.values.tolist()
          elif isinstance(data, np.ndarray):
              converted = data.tolist()
      elif to == "dataframe":
          if isinstance(data, pd.DataFrame):
              converted = data
          elif isinstance(data, np.ndarray):
              converted = pd.DataFrame(data)
      else:
          raise ValueError("Unknown data conversion: {}".format(to))
      if converted is None:
          raise TypeError(
              "cannot handle data conversion of type: {} to {}".format(
                  type(data), to
              )
          )
      else:
          return converted
  
file_path: sweetviz/sweetviz/from_dython.py
imports: import numpy
  import pandas
  from collections import Counter
  import math
  import scipy.stats
label_desc: Use image node_id 1 for calling a global function with example usage: convert(data, to) and returns: converted