title: get the mean of colum after concatenating adding one column at the end of another in pandas
body: <p>I have a dataset that looks like this :</p>
  
  <pre><code>    Interactor A    Interactor B    Interaction Score   score2
  0   P02574  P39205  0.928736    0.375000
  1   P02574  Q6NR18  0.297354    0.166667
  2   P02574  Q7KML4  0.297354    0.142857
  3   P02574  Q9BP34  0.297354    0.166667
  4   P02574  Q9BP35  0.297354    0.16666
  
  data.shape = (112049, 5)
  </code></pre>
  
  <p>I want to add <code>Interactor B</code> at the end of <code>Interactor A</code> column uniquely and add a column that shows their Rank. 
  I did this by :</p>
  
  <pre><code>cols = [data[col].squeeze() for col in data[['Interactor A','Interactor B']]]
  n =pd.concat(cols, ignore_index=True)
  n = pd.DataFrame(n,columns = ['AB'])
  </code></pre>
  
  <p>to make the column unique :</p>
  
  <pre><code>t = pd.unique(n['AB'])
  t= pd.DataFrame(t, columns=[ "AB"])
  </code></pre>
  
  <p>then :</p>
  
  <pre><code>t2 = n.groupby(['AB'],sort=False).size()
  t2 = pd.DataFrame(t2)
  </code></pre>
  
  <p>finally :
  by concatenating t2 and t   :</p>
  
  <pre><code>data_1 = pd.concat([t,l], axis=1)
  
  
  AB  Rank
  0   P02574  4
  
  
  data.shape = (13631, 2)
  </code></pre>
  
  <p>now I want to add the <code>Interaction Score</code>   and  <code>score2</code> column to DF . if there is duplicate take the mean of their <code>Interaction Score</code>  and delete the duplicates and replace the value of the <code>Interaction Score</code> by the mean.</p>
  
  <p>I used : </p>
  
  <pre><code>score2 = data.groupby(['Interactor A','Interactor B'])['score2'].mean()
  score2 = pd.DataFrame(score2, columns=['score2']) 
  </code></pre>
  
  <p>the output in this case is like :</p>
  
  <pre><code>        score2
  Interactor A    Interactor B    
  A0A023GPK8  Q9VQW1  0.200000
  A0A076NAB7  Q9VYN8  0.000000
  A0A0B4JD97  Q400N2  0.000000
  Q9VC64  0.090909
  Q9VNE4  0.307692
  
  112049 rows × 1 columns
  </code></pre>
  
  <p>but what I is to add columns with  mean of <code>'score2'</code> and <code>'Interaction Score'</code> column for 13631 unique data that I made. How can achieve this ?? please help.
  the final df should be like :</p>
  
  <p>Interactor  Rank    Interaction Score   score2
   P02574      5        0.928736              0.44</p>
  
  <p>ie: score2 is the average of all 'P0257' score that have been in the dataset</p>