code: def _encode_target(data, target, mapping=None):
      
      if mapping is None:
          mapping = {t: i for i, t in enumerate(sorted(data[target].unique()))}
  
      data[target] = data[target].apply(lambda t: mapping[t])
      return data, mapping
docs: Encode targets to integers in [0, num_classes - 1]