title: Python Pandas groupby assignment of object dtypes
body: <p>This python <code>DataFrame</code>:    </p>
  
  <pre><code>df = pd.DataFrame({'ID': [3553102778, 3553102958, 3553103948, 3553103948, 3553104038, 3553104038, 3553104128, 3553104218, 3557580098], 'Based on': ['CTR', 'CTR', 'Conv rate', 'CTR', 'Conv rate', 'CTR', 'CTR', 'CTR', 'CTR']}, columns=['ID', 'Based on'])
  </code></pre>
  
  <p>Produces a DataFrame that looks like this:</p>
  
  <pre><code>           ID   Based on
  0  3553102778        CTR
  1  3553102958        CTR
  2  3553103948  Conv rate
  3  3553103948        CTR
  4  3553104038  Conv rate
  5  3553104038        CTR
  6  3553104128        CTR
  7  3553104218        CTR
  8  3557580098        CTR
  </code></pre>
  
  <p>Notice how <code>ID</code> <code>3553103948</code> and <code>3553104038</code> have both <code>Conv rate</code> and <code>CTR</code>?</p>
  
  <p>How do I group this by <code>ID</code> but also assign <code>Based on</code> the value of <code>Conv rate, CTR</code> to get this?</p>
  
  <pre><code>           ID        Based on
  0  3553102778             CTR
  1  3553102958             CTR
  2  3553103948  Conv rate, CTR
  4  3553104038  Conv rate, CTR
  6  3553104128             CTR
  7  3553104218             CTR
  8  3557580098             CTR
  </code></pre>
  
  <p>I think it's some kind of <code>groupby</code> and assignment one-liner but I don't know how to detect if other <code>ID</code>s exist outside the row that are equal to the current row's <code>ID</code>.</p>
  
  <p>Maybe a <code>groupby</code> in conjunction with <code>apply</code>?  I'm not familiar with <code>apply</code> yet.</p>