title: How to create a new column based on specific considerations of other columns - Python
body: <p>I have a table with 3 columns. I need to create a new column (<code>Buy_intention</code>).</p>
  <pre><code>email_proposta             Difference       Mean   Buy_intention
  </code></pre>
  <p><a href="https://i.stack.imgur.com/mwcAq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mwcAq.png" alt="enter image description here" /></a></p>
  <p>The new column should be follow the rule, for the same email_proposta (sometimes email_proposta repeats several times), if the Difference is greater than the Mean, receive number 1, else 0.
  If <code>df['Difference']&gt;df['media']</code> return 1.
  Afterwards I will add all the numbers grouped by email_proposta. Then I will know of number of periods of purchase intent by customer.</p>