title: Pandas calculate average value of column for rows satisfying condition
body: <p>I have a dataframe containing information about users rating items during a period of time. It has the following semblance :    <a href="https://i.stack.imgur.com/8rytV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8rytV.png" alt="enter image description here" /></a></p>
  <p>In the dataframe I have a number of rows with identical 'user_id' and 'business_id' which i retrieve using the following code :</p>
  <pre><code>mask = reviews_df.duplicated(subset=['user_id','business_id'], keep=False) 
  dup = reviews_df[mask]
  </code></pre>
  <p>obtaining something like this :<br />
  <a href="https://i.stack.imgur.com/G681x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G681x.png" alt="enter image description here" /></a></p>
  <p>I now need to remove all such duplicates from the original dataframe and substitute them with their average. Is there a fast and elegant way to achive this?Thanks!</p>