code: def _apply_randomized_mapping(
      df, dfMap, features=[], random_seed=None
  ):
      """Apply Randomized mapping to create a new dataframe
  
      Args:
          df (DataFrame): Input dataframe
          dfMap (DataFrame): Mapping parameters
          features (list): Feature names for which the mapping needs to be applied
          random_seed (int): Random seed
  
      Returns:
          Perturbed version of df according to the randomizedmapping
      """
  
      if random_seed is not None:
          np.random.seed(seed=random_seed)
  
      df2 = df[features].copy()
      rem_cols = [l for l in df.columns if l not in features]
      if rem_cols != []:
          df3 = df[rem_cols].copy()
  
      idx_list = [tuple(i) for i in df2.itertuples(index=False)]
  
      draw_probs = dfMap.loc[idx_list]
      draws_possible = draw_probs.columns.tolist()
  
      # Make random draws - as part of randomizing transformation
      def draw_ind(x):
          return np.random.choice(range(len(draws_possible)), p=x)
  
      draw_inds = [draw_ind(x) for x in draw_probs.values]
  
      df2.loc[:, dfMap.columns.names] = [
          draws_possible[x] for x in draw_inds
      ]
  
      if rem_cols != []:
          return pd.concat([df2, df3], axis=1)
      else:
          return df2
  
file_path: AIF360/aif360/algorithms/preprocessing/optim_preproc.py
imports: from warnings import warn
  import numpy
  import pandas
  from aif360.algorithms import Transformer
  from aif360.datasets import BinaryLabelDataset
label_desc: Use image node_id 1 for calling a global function with example usage: _apply_randomized_mapping(df, dfMap, features, random_seed) and returns: np, pd, df2