title: Join Two DataFrames While Preserving Index
body: <p>Consider data frame:</p>
  <pre><code>asdf=pd.DataFrame({'a1':[True,True,True,False,False],'a2':[False,False,False,True,True],'p':['p1','p2','p3','p2','p3']})
  
   
        a1     a2   p
  0   True  False  p1
  1   True  False  p2
  2   True  False  p3
  3  False   True  p2
  4  False   True  p3
  </code></pre>
  <p>I wish to create the data frame</p>
  <pre><code>      a1     a2 
  p
  p1   True  False 
  p2   True  True
  p3   True  True
  </code></pre>
  <p>Attempt at a solution: I have tried various permutations of &quot;+&quot;, &quot;pd.concat&quot;, and &quot;pd.merge&quot; (all attempts not shown for the sake of clarity):</p>
  <pre><code>print(asdf)
  print('\n\n\n')
  tmp1=asdf[asdf['a1']==True]
  tmp1.set_index('p',inplace=True)
  tmp2=asdf[asdf['a2']==True]
  tmp2.set_index('p',inplace=True)
  print(tmp1)
  print(tmp2)
  print()
  print(tmp1+tmp2)
  print()
  print(pd.concat([tmp1,tmp2],axis=1,join='outer'))
  print()
  print(pd.merge(tmp1,tmp2,how='outer',on='p'))
  </code></pre>
  <p>However, this does not give the required result, i.e. there are multiple columns with same key values. Any suggestions or resources to consult? Thank you!</p>