code: def gen_global_selector(
      n_features,
      term_names,
      term_types,
      unique_val_counts,
      importance_scores,
      round=3,
  ):
      # TODO: we should not use Pandas in a public interface like this
      records = []
      for term_idx in range(len(term_names)):
          record = {}
          record["Name"] = term_names[term_idx]
          # TODO: update the javascript to accept "nominal" or "ordinal" instead of "categorical"
          record["Type"] = (
              "categorical"
              if term_types[term_idx] == "nominal"
              or term_types[term_idx] == "ordinal"
              else term_types[term_idx]
          )
  
          if term_idx < n_features:
              record["# Unique"] = (
                  np.nan
                  if unique_val_counts is None
                  else unique_val_counts[term_idx]
              )
              # TODO: remove this.. we don't seem to use it
              record["% Non-zero"] = np.nan
  
              # if importance_scores is None:
              #     record["Importance"] = np.nan
              # else:
              #     record["Importance"] = importance_scores[term_idx]
          else:
              record["# Unique"] = np.nan
              record["% Non-zero"] = np.nan
              # record["Importance"] = np.nan
  
          records.append(record)
  
      # columns = ["Name", "Type", "# Unique", "% Non-zero", "Importance"]
      columns = ["Name", "Type", "# Unique", "% Non-zero"]
      df = pd.DataFrame.from_records(records, columns=columns)
      if round is not None:
          return df.round(round)
      else:  # pragma: no cover
          return df
  
imports: from itertools import count
  import numpy
  import pandas
label_desc: Use image node_id 2 for calling a global function with example usage: gen_global_selector(n_features, term_names, term_types, unique_val_counts, importance_scores, round) and returns: df, df