title: Pandas pivot table to replace multiple hit by a string
body: <p>I used pandas <code>melt</code> function to make a table which looks almost like,</p>
  
  <pre><code>ref   Class   Sam
  A      v1      1
  A      v2      1
  A      v2      1
  B      v1      1
  C      v2      1
  A      v1      2
  B      v2      2
  B      v3      2
  C      v1      2
  </code></pre>
  
  <p>And I was trying to create a matrix using <code>pivot_table</code> function</p>
  
  <pre><code>melt.pivot_table(index='ref', columns='Sam', values='Class', aggfunc=lambda x: ';'.join(x.unique())).fillna('')
  </code></pre>
  
  <p>Which gives me something like this</p>
  
  <pre><code>      1        2
  A   v1;v2     v1
  B     v1     v2;v3
  C     v2      v1
  </code></pre>
  
  <p>Instead, I want to edit this code in such a way it replaces the multiple occurrences to a string while keeping the single occurrences as such.</p>
  
  <p>For example;</p>
  
  <pre><code>      1        2
  A  MultiHit   v1
  B     v1    MultiHit
  C     v2      v1
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p>Please let me know if my question wasn't clear.</p>