title: Fastest way to transpose this table while doing an operation
body: <p>I have this:</p>
  <pre><code>name phenotype
  ID1      tall
  ID2      tall
  ID3     short
  ID4      tall
  </code></pre>
  <p>I want this:</p>
  <pre><code>ID1  ID2  ID3  ID4 phenotype
  yes  yes   no  yes      tall
  no   no  yes   no     short
  </code></pre>
  <p>I have tried this approach:</p>
  <pre><code>df = pd.DataFrame({'name' : ['ID1', 'ID2', 'ID3', 'ID4'], 'phenotype' : ['tall', 'tall', 'short', 'tall']})
  
  sample_dict = {}
  for sample in df['name']:
      var_list = []
      for variant in df['phenotype'].unique():
          sample_subset = df[df['name'] == sample]
          if variant in sample_subset['phenotype'].to_list():
              var_list.append('yes')
          else:
              var_list.append('no')
  
          sample_dict[sample] = var_list
  sample_dict['phenotype'] = ['tall', 'short']
  sample_df = pd.DataFrame(sample_dict)
  </code></pre>
  <p>Is there a better and faster to transpose this table while performing the operation I describe?</p>