code: def collapse_phenotypes(self,input_phenotype_labels,output_phenotype_label,verbose=True):
          if isinstance(input_phenotype_labels,str): input_phenotype_labels = [input_phenotype_labels]
          bad_phenotypes = set(input_phenotype_labels)-set(self.phenotypes)
          if len(bad_phenotypes) > 0: raise ValueError("Error phenotype(s) "+str(bad_phenotypes)+" are not in the data.")
          data = self.copy()
          if len(input_phenotype_labels) == 0: return data
          def _swap_in(d,inputs,output):
              overlap = set(d.keys()).intersection(inputs)
              if len(overlap) == 0: return d
              keepers = [(k,v) for k,v in d.items() if k not in inputs]
              return dict(keepers+\
                          [(output_phenotype_label,max([d[x] for x in overlap]))])
          data['phenotype_calls'] = data.apply(lambda x:
              _swap_in(x['phenotype_calls'],input_phenotype_labels,output_phenotype_label)
              ,1)
          def _set_label(d):
              vals = [k for k,v in d.items() if v==1]
              return np.nan if len(vals) == 0 else vals[0]
          data['phenotype_label'] = data.apply(lambda x:
                  _set_label(x['phenotype_calls']),1)
          return data