code: def woe(df, feature_name, target_name):
      
  
      def group_woe(group):
          event = float(group.sum())
          non_event = group.shape[0] - event
  
          rel_event = event / event_total
          rel_non_event = non_event / non_event_total
  
          return np.log(rel_non_event / rel_event) * 100
  
      if df[target_name].nunique() > 2:
          raise ValueError('Target column should be binary (1/0).')
  
      event_total = float(df[df[target_name] == 1.0].shape[0])
      non_event_total = float(df.shape[0] - event_total)
  
      woe_vals = df.groupby(feature_name)[target_name].transform(group_woe)
      return woe_vals
docs: Calculate weight of evidence.
  
      Parameters
      ----------
      df: Dataframe
      feature_name: str
          Column name to encode.
      target_name: str
          Target column name.
  
      Returns
      -------
      Series