code: def categorize(values, categories, default=None):
      
      uniq_cats = list(unique_iterator(values))
      cats = []
      for c in values:
          if isinstance(categories, list):
              cat_ind = uniq_cats.index(c)
              if cat_ind < len(categories):
                  cat = categories[cat_ind]
              else:
                  cat = default
          else:
              cat = categories.get(c, default)
          cats.append(cat)
      return np.asarray(cats)
docs: Maps discrete values to supplied categories.
  
      Replaces discrete values in input array with a fixed set of
      categories defined either as a list or dictionary.
  
      Args:
          values: Array of values to be categorized
          categories: List or dict of categories to map inputs to
          default: Default value to assign if value not in categories
  
      Returns:
          Array of categorized values