text: def create_map():
      ## List of tuples with name and number of repititons.
      name_list = [('infections', 139),
                  ('neoplasms', (239 - 139)),
                  ('endocrine', (279 - 239)),
                  ('blood', (289 - 279)),
                  ('mental', (319 - 289)),
                  ('nervous', (359 - 319)),
                  ('sense', (389 - 359)),
                  ('circulatory', (459-389)),
                  ('respiratory', (519-459)),
                  ('digestive', (579 - 519)),
                  ('genitourinary', (629 - 579)),
                  ('pregnancy', (679 - 629)),
                  ('skin', (709 - 679)),
                  ('musculoskeletal', (739 - 709)),
                  ('congenital', (759 - 739)),
                  ('perinatal', (779 - 759)),
                  ('ill-defined', (799 - 779)),
                  ('injury', (999 - 799))]
      ## Loop over the tuples to create a dictionary to map codes 
      ## to the names.
      out_dict = {}
      count = 1
      for name, num in name_list:
          for i in range(num):
            out_dict.update({str(count): name})  
            count += 1
      return out_dict
    
  
  def map_codes(df, codes):
      import pandas as pd
      col_names = df.columns.tolist()
      for col in col_names:
          temp = [] 
          for num in df[col]:           
              if ((num is None) | (num in ['unknown', '?']) | (pd.isnull(num))): temp.append('unknown')
              elif(num.upper()[0] == 'V'): temp.append('supplemental')
              elif(num.upper()[0] == 'E'): temp.append('injury')
              else: 
                  lkup = num.split('.')[0]
                  temp.append(codes[lkup])           
          df.loc[:, col] = temp               
      return df 
  
  def azureml_main(df):
      col_list = ['diag_1', 'diag_2', 'diag_3']
      codes = create_map()
      df[col_list] = map_codes(df[col_list], codes)
      return df
      