title: Pandas - filter rows with same value in one column and multiple values in another column based on the existence of a value in the latter column
body: <p>I have the following base table that I would like to separate out into a has guava table and a does not have guava table. I'm thinking of using a flag to get the intermediate table below but not sure where to go from there.</p>
  <p>base table</p>
  <pre><code>user_id fruit  
  user1   passionfruit  
  user1   guava
  user1   banana
  user2   orange
  user2   coconut
  user3   guava
  user4   melon
  </code></pre>
  <p>has guava</p>
  <pre><code>user_id fruit  
  user1   passionfruit  
  user1   guava
  user1   banana
  user3   guava
  </code></pre>
  <p>does not have guava</p>
  <pre><code>user_id fruit  
  user2   orange
  user2   coconut
  user4   melon
  </code></pre>
  <p>intermediate table</p>
  <pre><code>user_id fruit        has_guava
  user1   passionfruit 0 
  user1   guava        1
  user1   banana       0
  user2   orange       0
  user2   coconut      0
  user3   guava        1
  user4   melon        0
  </code></pre>