title: Sort unique by several columns, then merge values in non-matching columns
body: <p>Consider a bed file containing genetic variants:</p>
  
  <blockquote>
  CHR START STOP RSID REF/ALT PHENOTYPE PVALUE<br>
  1 987654321 987654322 rs123456 A/T Height 6E-9<br>
  1 987654321 987654322 rs123456 A/T Stroke 8E-15
  </blockquote>
  
  <p>I want to sort unique by the first 5 columns, and then merge the contents in the columns that have unique values:</p>
  
  <p>Example output:</p>
  
  <blockquote>CHR START STOP RSID REF/ALT PHENOTYPE PVALUE<br>
  1 987654321 987654322 rs123456 A/T <b>Height,Stroke 6E-9,8E-15</b>
  </blockquote>
  
  <p>Is this possible in Python or Unix? Or do I need to write a script?</p>
  
  <p>If it is possible in Python or Unix, what function allows me to do that?</p>
  
  <hr>
  
  <p>This question was addressed <a href="https://stackoverflow.com/questions/46275765/pandas-merge-row-data-with-multiple-values-to-python-list-for-a-column">here</a> but never solved.</p>