title: How to assign a variable value depending on a condition on a pandas dataframe?
body: <p>I have a dataframe that looks like this:</p>
  
  <pre><code>    number       type   username  product publishing_dt          genres  count
  0        1     access   kerrigan      897    2019-03-05             VXA      0
  1        1     access   kerrigan     1459    2008-05-06         VXA,VHS      0
  2        1  orderline  45michael    76863    2019-10-04        VXA,B,GT      1
  3        1  orderline  45michael    86833    2020-02-04          VS,KJM      1
  4        1  orderline  45michael   130365    2020-02-10   VXA,GT,B,JFSS      1
  5        1  orderline    alicia7   130365    2020-02-10   VXA,GT,B,JFSS      1
  6        1  orderline     angel8    86217    2017-01-06           B,GTE      1
  7        1  orderline      john5    86833    2020-02-04          VS,KJM      1
  8        1  orderline      john5   130365    2020-02-10   VXA,GT,B,JFSS      1
  9        1  orderline   kerrigan    76863    2019-10-04        VXA,B,GT      1
  10       1  orderline   kerrigan  1023897    2020-01-07          GT,VHS      1
  11       1  orderline     kylemm   537077    2017-05-07          VXA,GT      1
  12       1  orderline     uololo   830166    2019-12-05           VXA,B      1
  13       3     access     7762hc    84325    2018-04-03  VHS,GT,GTE,VXA      0
  14       4     access   adrian12   997165    2016-02-01            B,GT      0
  15       4     access   kerrigan     5467    2020-01-24         VXA,VHS      0
  16       4     access      yvera    76863    2019-10-04        VXA,GT,B      0
  17       5     access   kerrigan   130365    2020-02-10   VXA,GT,B,JFSS      0
  18       6     access   kerrigan     2345    2020-02-01         VXA,VHS      0
  19       7     access   kerrigan    78921    2019-11-03          GTE,BS      0
  20       7     access   kerrigan    86833    2020-02-04          VS,KJM      0
  21       8     access   kerrigan      645    2020-02-10         VXA,VHS      0
  22      10     access  45michael    63767    2020-01-01        GT,B,VHS      0
  </code></pre>
  
  <p>Where <em>type</em> indicates the type of access the user has made to the product (if it was a <strong>purchase</strong> ('<em>orderline</em>') or if it was a <strong>visit</strong> ('<em>access</em>'), <em>product</em> is the unique identifier of the product in question, <em>number</em> is the number of times a user has accessed the product (<em>if type == access</em>) and <em>count</em> represent the number of times a user bought a product.</p>
  
  <p>I want to change the <em>count</em> value so it goes <strong>from 0 to 1</strong>, where 0 would represent not bought and not purchased and 1 purchased, and the values between a proportion corresponding to the number of accesses, so it could be 0.9 for 20 or more times, 0.5 for 10 times and so on.</p>
  
  <p>Any idea on how can I do this?</p>
  
  <p>Expected output:</p>
  
  <pre><code>    number       type   username  product publishing_dt          genres  count
  0        4     access   kerrigan      897    2019-03-05             VXA    0.2
  1       10     access   kerrigan     1459    2008-05-06         VXA,VHS    0.5
  2        1  orderline  45michael    76863    2019-10-04        VXA,B,GT    1.0
  3        1  orderline  45michael    86833    2020-02-04          VS,KJM    1.0
  4       15     access  45michael   130365    2020-02-10   VXA,GT,B,JFSS    0.8
  </code></pre>